python 类型语法注释
python 3.5 引入的一种注释语法 编译器自动忽略
- 仅仅IDE识别使用
x = 1 # type: int
y = 'hello' # type: str
函数的注释 可以通过 doc 获取
from functools import wraps
def my_decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
"""my_decorator wrapper"""
print("Before calling the function")
result = func(*args, **kwargs)
print("After calling the function")
return result
return wrapper
@my_decorator
def say_hello():
"""say_hello"""
print("Hello!")
if __name__ == '__main__':
print(say_hello.__name__)
print(say_hello.__doc__)
requirestment.txt
- 是一种社区标准
- 2 和 3 都是支持
pip freeze > requirements.txt
pip install -r requirements.txt
虚拟环境是3.3引入的
python -m venv myenv
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/18599706