我只想删除1214"
在"ilanlar\u0131 1214", "count""
或删除 2808"
在"ilanlar\u0131 2808", "count""
。如何在 python 中使用正则表达式?
我尝试了这段代码。
for line in fileinput.input('sektorler.json', inplace=True):
print(line.replace("^\d+\," , ""))
最佳答案
您需要使用re.sub
,它将正则表达式作为第一个参数。 replace
方法必须采用字符串作为参数。
re.sub(r'\d+"', "", strin)
关于python - 使用正则表达式删除数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30694523/