配置
pip 使用清华源
pip install --upgrade torch==1.4.0 torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple
python关键字
>>import keyword
>>keyword.kwlist
>>['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
字符串(String)
- 反斜杠可以用来转义,使用 r 可以让反斜杠不发生转义。。 如 r"this is a line with \n" 则\n会显示,并不是换行。
- 字符串可以用 + 运算符连接在一起,用 * 运算符重复。
Python3 模块
name属性
说明: 每个模块都有一个name属性,当其值是’main’时,表明该模块自身在运行,否则是被引入。
if __name__ == '__main__':
print('程序自身在运行')
else:
print('我来自另一模块')