代码格式化
Table of Contents
为什么要格式化代码
- 保持代码更可读。
怎么保持?
- 使用Linting python‘s is Pylint
pip install pylint
# vscode 代码保存后自动运行pylint
- 使用 ctrl + shift + p 输入linting 可启用/不启用pylint
类型提示 Type hints | 文档字符串 Doc string
def print_hello(name:str) -> str:
"""
Returns a greeting
Parameters:
name(str): The name of the person
Returns:
The cool message
"""
print('Hello, ' + name)
print_hello('tian')