#Author:Timmy import my_module import sys my_module.sayhi('jack') print(sys.path) for i in sys.path: print(i)
#!/usr/bin/python # -*- coding: utf-8 -*- # Filename: my_module_demo2.py from my_module import sayhi, version # ή αλλιώς: # from mymodule import * sayhi() print 'Έκδοση:', version
my_module.py name = "alex" print("hello",name) def sayhi(n): print("hi,", n) ------------------------------- my_module2.py import my_module my_module.sayhi("jack") #hello alex #hello jack #模块 模块查找路径有关系
import my_module my_module.sayhi() print(my_module.__version__) print(dir(my_module)) dir(my_module)
#!/usr/bin/python # -*- coding: utf-8 -*- # Filename: my_module_demo.py import my_module my_module.sayhi() print 'Version', my_module.version
from my_module import sayhi, version # Alternative: # from mymodule import * sayhi() print 'Version', version
import my_module my_module.sayhi("小猿圈")