练习题: 使用以上三选一的方式,完成多进程程序同时写操作多个文件。 比如,同时启动三个子进程,分别写三个不同文件 A文件中存储随机大写字母 B文件中存储随机小写字母 C文件中存储随机数字
import time
from multiprocessing import Process #多进程模块
import random
def fun():
count = 0
while True:
with open("xiaoxie.txt", "w+") as f:
for i in range(5):
buff2 = chr(random.randrange(97, 122))
f.write(buff2)
with open("xiaoxie.txt", "r+") as f:
print(f.read())
time.sleep(1)
count +=1
if count >=10:
break
def fun2():
count = 0
while True:
with open("shuzi.txt", "w+") as f:
for i in range(5):
buff1 = chr(random.randrange(48, 57))
f.write(buff1)
with open("shuzi.txt", "r+") as f:
pr