#输入王小明,输出王 小明 #读取原始txt文件 with open('D:\\PCCW_Test_Script\\111.txt', encoding='utf-8') as file1: content = file1.readlines() # print(content) with open('D:\\PCCW_Test_Script\\222.txt', "w", encoding='utf-8') as file2: for name in content: name=name.strip() name_parts = name[:1]+ str(" ")+ name[1:] # print(name_parts) file2.write(name_parts + '\n')
标签:字符,分割,name,Script,python,file1,content,parts,txt From: https://www.cnblogs.com/yi-ying/p/17585177.html