2019年12月17日
摘要: 线程与线程之间数据是共享的 from threading import Thread def func(lst, name): lst.append(66) print(name, lst) if __name__ == '__main__': lst = [1, 2] t1 = Thread(ta 阅读全文
posted @ 2019-12-17 16:15 lilyxiaoyy 阅读(1196) 评论(0) 推荐(1) 编辑
摘要: 进程与进程之间数据是隔离的 from multiprocessing import Process def func(lst, name): lst.append(66) print(name, lst) if __name__ == '__main__': lst = [1, 2] p1 = Pr 阅读全文
posted @ 2019-12-17 15:17 lilyxiaoyy 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 心得: 1.要实现多用户同时登陆,需要使用多进程,不能使用多线程,因为多线程数据是共享的,在用户切换目录的时候,会出现问题,而多进程由于数据是隔离的,就没有这个问题。 2.切换目录和删除文件的时候,需要检查要切换或删除的目录是否超出了用户的家目录。需要用到 user_full_home = os.p 阅读全文
posted @ 2019-12-17 14:55 lilyxiaoyy 阅读(1690) 评论(0) 推荐(0) 编辑
摘要: 写法一 import time from threading import Thread def func(name): print(f"{name}开始") time.sleep(0.5) print(f"{name}结束") if __name__ == '__main__': t1 = Thr 阅读全文
posted @ 2019-12-17 14:39 lilyxiaoyy 阅读(7979) 评论(0) 推荐(0) 编辑

返回
顶部