python IO
读文件
with open('raw.txt','r') as file:
for line in file.readlines():
city=line.strip().split()[1]
写文件
with open(args.output, 'w') as file:
file.write(f'size={args.size}, nhead={args.nhead}, dropout={args.dropout}, batch-size={args.batch_size}\n')
for nid, name in id_name.items():
file.write('{}\t{}\n'.format(name, ' '.join(embeddings[nid].astype(str))))
## 格式化处理
1. format
2. %