这里写自定义目录标题
python字符串一次替换多个字符使用replace替换多处
遇到问题,如何替换爬取的时间数据是用中文字符保存的,如1997年6月6日,想要替换成1997-6-6,方法如下
def change_Time_Type(times):
new_times = []
for i in range(len(times)):
new_times.append(times[i].replace("年", "-").replace("月", "-").replace("日", ""))
print(new_times)
return new_times
清除段前段后空格或字符方法
str = "*****this is **string** example....wow!!!*****"
print (str.strip( '*' )) # 指定字符串 *
print (str.strip( )) #清除空格