(+CMGL: 2,"REC READ","DD-Etopup",,"11/11/04,12:48:51+22" Hye! How's it going?)
I want to store this sms message in python as a string. How can I do this?
三重引号 - 这将允许嵌入的单引号和双引号,而不包含转义字符。
s = """(+CMGL: 2,"REC READ","DD-Etopup",,"11/11/04,12:48:51+22" Hye! How's it going?)"""
Backslash escaping is the quick answer:
>>> '(+CMGL: 2,"REC READ","DD-Etopup",,"11/11/04,12:48:51+22" Hye! How\'s it going?)'
'(+CMGL: 2,"REC READ","DD-Etopup",,"11/11/04,12:48:51+22" Hye! How\'s it going?)'
>>> a = '(+CMGL: 2,"REC READ","DD-Etopup",,"11/11/04,12:48:51+22" Hye! How\'s it going?)'
>>> a.split(',')
['(+CMGL: 2', '"REC READ"', '"DD-Etopup"', '', '"11/11/04', '12:48:51+22" Hye! How\'s it going?)']
>>> a.split(',')[5]
'12:48:51+22" Hye! How\'s it going?)'
>>> len(a.split(',')[5])
34
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.