基础补充

1. python3中,中文也可以作为变量名,非ASCII标识符也能允许。

2. 保留字也就是关键字,python的标准库提供了一个keyword模块,可以输出当前版本的所有关键字。python3.6有33个关键字。

import keyword
keyword_num = keyword.kwlist
print(len(keyword_num))

3.print 默认输出是换行的,如果要实现不换行需要在变量末尾加上 end="  "

4. import 和 from import

在 python 用 import 或者 from...import 来导入相应的模块。

将整个模块(somemodule)导入,格式为: import somemodule

从某个模块中导入某个函数,格式为: from somemodule import somefunction

从某个模块中导入多个函数,格式为: from somemodule import firstfunc, secondfunc, thirdfunc

将某个模块中的全部函数导入,格式为: from somemodule import *