【发布时间】:2017-02-22 11:09:53
【问题描述】:
我尝试使用python编写脚本,删除html中的某个模式文本。但是,我的代码似乎不起作用..您能帮我检查一下哪里出错了吗?
import os, re
cwd = os.getcwd()
print ('Now you are at this directory: \n' + cwd)
# find files that have an extension with HTML
Files = os.listdir(cwd)
print Files
def func(file):
for file in os.listdir(cwd):
if file.endswith('.html'):
for line in open(file):
re.sub(r'<strong>.*?<\/strong>', '', line)
# I feel the above line has some problems
func(file)
非常感谢您!
【问题讨论】: