2024-06-25 07:26:18 发布
网友
例如,如果我有
'address": [{"type": null, "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States"}]',
我希望是这样
'address [type null value 1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States]'
您只需按以下方式使用“替换”:
my_str = 'define_your_string_here' to_be_replaced = [':','\"','{','}'] for rep in to_be_replaced: my_str = my_str.replace(rep, '')
您可以使用Python的String的^{}方法
>>> YourString = 'address": [{"type": null, "value": "1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States"}]' >>> YourString.replace('"', '').replace('{', '').replace('}', '').replace(':', '').replace(',', '') 'address [type null value 1600 Amphitheatre Parkway\nMountain View\nCA\n94043\nUnited States]'
您只需按以下方式使用“替换”:
您可以使用Python的String的^{} 方法
相关问题 更多 >
编程相关推荐