37 lines
758 B
Python
37 lines
758 B
Python
# # 模块导入
|
|
# import time
|
|
# time.sleep(5)
|
|
# print("你好")
|
|
|
|
# from time import sleep
|
|
# sleep(2)
|
|
# print(2)
|
|
|
|
# 导入自定义模块
|
|
# import my_test as t
|
|
# .test(2,4)
|
|
# # 导入不同模块同名的功能
|
|
# from my_test import test
|
|
# from my_test1 import test
|
|
#
|
|
# test(2,5)# 下面的会将上面的覆盖掉
|
|
|
|
# __main__变量
|
|
# import my_test as t
|
|
# 调用的模块本身调用了函数,则调用时候会输出结果
|
|
|
|
# # __all__ 变量
|
|
# from my_test import *
|
|
#
|
|
# test(1, 2)
|
|
# test1(3, 8) # 未定义时,可以使用任意函数
|
|
# # all定义时,只能导入定义的函数,但只作用于*,可以手动单独导入函数
|
|
|
|
# python的包
|
|
import my_package.my_test1
|
|
my_package.my_test1.test()
|
|
from my_package.my_test2 import test
|
|
test()
|
|
|
|
|