模块理解:为把功能逻辑写入后缀名为py的文件里面,根据需要可以任意调用。 模块使用:1.用import,在A的模块里面想用B的成员(变量,函数,类),如果只使用import是导入所有的,用的时候形式:模块.方法。 2.from从某某里面导入具体的方法或对象是可以直接写。 import math from models import page import models 为了解决不同模块下重名对象的问题可以用as起别名 from models import test as m_test 调包 import a.product def hello(): print('hello') print(page) 可以直接调用 hello() 可以通过入口文件调用 if __name__=='__main__': hello() m_test()
python第7天包与模块管理
最新推荐文章于 2024-08-29 10:04:09 发布