标签:key loading port str for col txt with open span
f = open(r‘data6_1.txt‘) f1=open(‘data6_2.txt‘,‘w‘) a = list(f) a.sort(key=lambda x : x[8:]) a.reverse() for i in a: i=i.strip(‘\n‘) f1.write(‘‘.join(i)) f1.write(‘\n‘) print(‘‘.join(i))
import random name_num = eval(input(‘请输入抽点人数:‘)) m = set() with open(‘data7.txt‘,‘r‘) as f: a = f.readlines() while len(m)<name_num: b = random.randint(0,len(a)-1) m.add(a[b]) import datetime time = datetime.datetime.now() x = time.strftime(‘%Y%m%d‘) with open(x+‘.txt‘,‘w‘) as n: for i in m: n.write(i) print(i)
标签:key loading port str for col txt with open span
原文地址:https://www.cnblogs.com/wuyuhao020324/p/14780428.html