在test6_8.py文件中,可以这样定义变量和函数:
data = "hello"
def showdata():
print(data)
print("模块test6_8.py中的showdata()函数被调用了……")
在test.py文件中,可以这样导入模块并调用函数:
import test6_8
test6_8.showdata()
这样,当你在test.py中运行这段代码时,就会先输出变量data的值,再输出"模块test6_8.py中的showdata()函数被调用了……"的消息。