string.strip("'") # strips single quotes away
string.strip('"') # strips double quotes
string.strip("'\"") # both single and double quotes. The double quote in the middle is 'escaped' by the backslash character
或者
string = string.replace("'", "") # replaces single quotes in the string with nothing
string = string.replace('"', '') # for double quotes
使用replace:
strip
完全符合您的目的。只需要求它删除引用:您可以执行以下操作之一:
或者
相关问题 更多 >
编程相关推荐