例如,我有一个句子,例如:Jamie's car broke "down" in the middle of the street如何在不手动删除引号和引号的情况下将其转换为字符串,例如:'Jamies car broke down in the middle of the street'任何帮助表示赞赏!谢谢,
3 回答
摇曳的蔷薇
TA贡献1793条经验 获得超6个赞
replace()一个接一个地使用:
s = """Jamie's car broke "down" in the middle of the street"""
print(s.replace('\'', '').replace('"', ''))
# Jamies car broke down in the middle of the street
翻阅古今
TA贡献1780条经验 获得超5个赞
试试这个:
oldstr = """Jamie's car broke "down" in the middle of the street""" #Your problem string
newstr = oldstr.replace('\'', '').replace('"', '')) #New string using replace()
print(newstr) #print result
这将返回:
Jamies car broke down in the middle of the street
添加回答
举报
0/150
提交
取消