【发布时间】:2017-04-13 14:19:07
【问题描述】:
我有一个字符串数组,并且想做一些替换。例如:
my_strings = [['hi / hello world &'], ['hi / hello world'], ['it\90s the world'], ['hello world'], ['hello "world"']]
new_strings = [['hi and hello world'], ['hi and hello world'], ["it's the world"], ['hello world'], ['hello world']]
如果数组中的字符串包含这些字符,如何将 / 替换为 and,删除 & 和 \90,以及删除单词周围的 ""?
【问题讨论】:
-
看看官方文档中的replace方法:docs.python.org/2/library/string.html
-
实际上,您没有字符串数组。使用你的用词不当(它应该是“列表”,而不是“数组”),你有一个字符串数组的数组。每个字符串周围有额外的
[和]有什么原因吗?
标签: python string python-2.7