嗨,通常在使用Javascript时,我使用Python提供的json模块。它将转义该字符串以及user2357112指出的其他内容。
import jsonstring = 'This sentence has some "quotes" in itn'json.dumps(string) #gives you '"This sentence has some \"quotes\" in it\n"'

嗨,通常在使用Javascript时,我使用Python提供的json模块。它将转义该字符串以及user2357112指出的其他内容。
import jsonstring = 'This sentence has some "quotes" in itn'json.dumps(string) #gives you '"This sentence has some \"quotes\" in it\n"'