1.import
搜索路径
import sys sys.path
路径搜索
从上⾯列出的⽬录⾥依次查找要导⼊的模块⽂件
' '
表示当前路径
程序执⾏时导⼊模块路径
sys.path.append('/home/itcast/xxx')
sys.path.insert(0,
'/home/itcast/xxx')
#可以确保先搜索这个路径
In [37]: sys.path.insert(0,"/home/python/xxxx")
In [38]: sys.path Out[38]:
['/home/python/xxxx',
'',
'/usr/bin',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages',
'/usr/lib/python3/dist-packages/IPython/extensions', '/home/python/.ipython']
2.
重新导入模块两种方法:
1.退出—重新导入
2.imp reload
模块被导⼊后,
import module 不能重新导⼊模块,重新导⼊需⽤