鍍金池/ 問答/Python/ 遇到數(shù)字,則通過 字符.replace替換成刪除

遇到數(shù)字,則通過 字符.replace替換成刪除

import os
import re

#所在文件路徑
file_path = os.listdir('F:/Python/第一周作業(yè)/task/')
 
for files in file_path: #遍歷所有
    file = open('F:/Python/第一周作業(yè)/task/' + files) 
    files_name = file.read()
    print(files_name)
    print("---------")
    #匹配數(shù)字
    find = re.findall(r"\d+", files_name)
    print(find)

之后怎么刪除數(shù)字??????

回答
編輯回答
只愛你
>>> import re
>>> p = re.compile('\d+')
>>> s = 'hello12 world334'
>>> re.sub('\d+', '', s)
'hello world'
2017年3月22日 02:22