【发布时间】:2018-04-09 19:51:49
【问题描述】:
我希望输出类似于周一下午 5:00 到凌晨 12:00。删除输出检查中的所有单引号和空格:代码如下
for count in glob.glob(os.path.join("C:\\Users\\test", "*.html")):
soup=BeautifulSoup(open(files), 'html.parser')
hours=soup.find_all( 'table', {'class' : "table"
[0].get_text().strip().split()
check=[i.encode('utf-8').strip().replace("-","to" ) for i in hours]
print check
当前输出:
['Mon', '5:00', 'pm', 'to', '12:00', 'am', 'Tue', '5:00', 'pm', 'to', '12:00', 'am']
【问题讨论】:
-
当前,它将输出打印为 ['Mon', '5:00', 'pm', 'to', '12:00', 'am', 'Tue', '5 :00', 'pm', 'to', '12:00', 'am']
-
['Mon', '5:00', 'pm', 'to', '12:00', 'am', 'Tue', '5:00', 'pm' , 'to', '12:00', 'am'
标签: python-2.7 list beautifulsoup