python 模块
认识模块 对于模块,在前面的一些举例中,已经涉及到了,比如曾经有过:import random (获取随机数模块)。为了能够对模块有一个清晰的了解,首先要看看什么模块,这里选取官方文档中对它的定义: A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended. Within a module, the module’s name (as a string) is available as the value of the global variablename. 模块就是一个含有python语句的文件 模块名就是文件名(不要扩展名.py) 那么,那个import random的文件在哪里呢? help()函数看看: >>> help(random) 然后就出现: NAME random - Random variable generators. FILE /usr/local/...