Python 之关键字和实例 0.0682018.04.09 20:10:28字数 1073阅读 2671 一.python关键字 Screen Shot 2018-04-09 at 19.50.17.png \1. and :表示逻辑判断 [与] a = '1' b = 1 if a and b: print('Hello Python') 2.as :单独没有实际意思,常与with组合使用,with...as 例如: with open('./test.txt', 'w') as f: f.…
Python assert(断言)可以分别后面的判断是否正确,如果错误会报错 示例: a = 1 assert type(a) is int print('No problem') 输出结果: No problem a = ' assert type(a) is int print('No problem') 输出结果: Traceback (most recent call last): File "D:/test.py", line 3, in <module> …