[英]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.