python模块之间的代码元素的访问
1.一个模块本质就是一个文件,在模块中封装了很多代码元素。
1)导入所有内容:import语句
2)只导入一个元素,from import
3)如果名称有冲突 from import as
# @File : world.py# @Software: PyCharm#coding=utf-8x=‘你好‘y=Truez=20.0
# @File : hello.py# @Software: PyCharm#coding=utf-8from test_module import worldfrom test_module.world import x as x2from test_module.world import zx=100y=20print(y) #访问当前模块变量yprint(world.y)#访问world模块变量yprint(z)#访问world模块变量zprint(x2) #x2是world模块x别名