创建一个程序test.py,在其中定义一个变量data,同时定义一个函数showdata()输出变量data的值。在程序test1.py中导入test.py,输出变量data的值。
注意:把两个文件放在同一目录下
test
data = "这是test中的data"
def show_data():
print(data)
test1
from test import show_data
show_data()
"""test.py"""
def showdata(data):
print(data)
"""test1.py"""
import test
test.showdata('Hello World')