标签:div code rev txt mic ftime png 图片 datetime
x = [] f = open(‘C:\\Users\\J&K\\Desktop\\实验4文档相关代码和数据文件\\实验4文档相关代码和数据文件\\data6_1.txt‘, encoding=‘utf_8‘) y = f.readlines() for i in y: x.append(i.strip().split()) a = lambda b: int(b[2]) x.sort(key=a, reverse=True) for i in x: print(‘ ‘.join(i)+‘\n‘) f.close() f = open(‘C:\\Users\\J&K\\Desktop\\实验4文档相关代码和数据文件\\实验4文档相关代码和数据文件\\data6_2.txt‘, ‘w‘, encoding=‘utf_8‘) for i in x: f.write(‘ ‘.join(i)+‘\n‘) f.close()
x = eval(input(print(‘请输入抽点人数:‘))) f = open(‘C:\\Users\\J&K\\Desktop\\实验4文档相关代码和数据文件\\实验4文档相关代码和数据文件\\data7.txt‘) y = f.readlines() z = [] for i in y: z.append(i.strip().split()) rolled = [] while len(rolled) < x: import random a = random.randint(1, 80) if a not in rolled: rolled.append(a) for i in rolled: print(y[i]) f.close() import datetime t = datetime.datetime.now() time = t.strftime(‘%Y%m%d‘) f = open(‘C:\\Users\\J&K\\Desktop\\实验4文档相关代码和数据文件\\实验4文档相关代码和数据文件\\‘+time+‘.txt‘, ‘w‘) for i in rolled: f.write(y[i]) f.close()
标签:div code rev txt mic ftime png 图片 datetime
原文地址:https://www.cnblogs.com/pengjinrong/p/14773818.html