def transferContent(self, content):
if content is None:
return None
else:
string = ""
for c in content:
if c == '"':
string += '\\\"'
elif c == "'":
string += "\\\'"
elif c == "\\":
string += "\\\\"
else:
string += c
return string
转载请注明:谷谷点程序 » python insert 转义字符串中的单引号,双引号等