[英]How can I remove forward slash(es) from an array of strings in Python?
我有一個這樣的數組
arrayOne = ['["https:\/\/somewebsite.com"]','["https:\/\/anotherwebsite.com"]', '["https:\/\/lastwebsite.com"]']
本質上,我要做的是從上面數組中的字符串中刪除正斜杠\
。 我是 python 初學者,所以我正在學習 go。 python 中是否有可以做到這一點的方法? 我正在使用 python 3.9。
成功的 output 如下所示:
arrayTwo = ['["https://somewebsite.com"]','["https://anotherwebsite.com"]', '["https://lastwebsite.com"]']
任何指導都會有所幫助!
非常感謝!
您可以對字符串 object 使用替換方法。 然后對數組中的每個 web url 使用列表理解。
arrayOne = [each.replace("\\","") for each in arrayOne]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.