fileinput = open('INFILE.txt', 'r')
fileoutput = fileinput.read()
replace = re.sub(r'([A-Za-z]),([A-Za-z])', r'\1\2', fileoutput)
print replace
replaceout = open('OUTFILE.txt', 'w')
replaceout.write(replace)
上面的代码删除任何信件中是否逗号或CapsLocks任何不信和之后的任何数字。如何在任何字母和数字之间插入逗号?我试试代码如何插入逗号之间使用正则表达式
replace = re.sub(r"([a-z])([0-9])", r",\1", fileoutput)
但它不起作用。任何建议如何在任何字母和数字之间插入逗号?
请显示您的文件中的示例输入以及您希望插入逗号的位置/方式。 –
Vilniausnuoma483,NuomaVilniuiiraplinkVilniu。我想在数字483之前插入逗号。 –