如何在python中存储包含单引号(')和双引号(“)的字符串 [英] How to store a string containing both single quote( ' ) and double quote( " ) in python

查看:1195
本文介绍了如何在python中存储包含单引号(')和双引号(“)的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(+CMGL: 2,"REC READ","DD-Etopup",,"11/11/04,12:48:51+22" Hye! How's it going?) 

我想以python的形式将这个短信存储为一个字符串。我该怎么做?

I want to store this sms message in python as a string. How can I do this?

推荐答案

三重引号 - 这将允许嵌入式单引号和双引号无转义字符。

Triple quotes - this will allow embedded single and double-quotes without escape characters.

s = """(+CMGL: 2,"REC READ","DD-Etopup",,"11/11/04,12:48:51+22" Hye! How's it going?)"""

这篇关于如何在python中存储包含单引号(')和双引号(“)的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆