import time
import threading
start_time = time.time()
def one():
for i in range(0,3):
print("学习1秒钟")
time.sleep(1)
def two():
for i in range(0,3):
print("看小姐姐1分钟")
time.sleep(1)
def main():
'''学习线程'''
# 设置线程/开辟线程
t1 = threading.Thread(target=one)
t2 = threading.Thread(target=two)
# 启动
t1.start()
t2.start()
# 运行结果 这两个函数同时进行
if __name__ == '__main__':
# one()
# two()
# time = time.time()
# all_time = start_time + time
# print("耗时(s):",all_time) # 耗时(s): 3184537087.996723
main()
线程 1
最新推荐文章于 2023-10-14 20:02:37 发布