python的import的几种形式:
在t1.py中
def out():
print('this is t1')
<pre name="code" class="python">def hello():
print('hello world')
在t3.py中
import t1
t1.out()
前面需要加上t1.来说明这是使用的t1文件
执行结果为
下面换种形式:
import t1
from t1 import out
out()
t1.hello()
还可以使用另一种形式:
from t1 import *
out()
hello()
注意此时前面不能加上t1.。