strip()可以去除頭尾的轉義符號,但不能去除字符串中間的
比如title = "13.\t13"
拿到手的就是變量title,無法直接加r變成原始字符串
這時候可以使用repr()方法
print(repr(title))
結果為'13.\t13',發現多了單引號
new_title = repr(title).replace(f'\\t', '')
print(new_title)
結果為:
'13.13'
再使用eval方法可以轉回字符串
new_title = eval(repr(title).replace(f'\\t', ''))
print(new_title)
結果為:
13.13
參考:
https://blog.csdn.net/qq_33692331/article/details/111414982