0

我正在通过 python 与串口通信。我传递了一个 AT 命令来列出电话目录。现在我需要获取我收到的电话号码。如何通过 python 获取该特定数字。

+CMGR: "REC READ","+911234567890",,"13/05/31,10:00:14+22"
4

2 回答 2

1

像这样的东西?

>>> import re
>>> strs = '+CMGR: "REC READ","+911234567890",,"13/05/31,10:00:14+22'
>>> re.search(r'"(\+91\d+)"', strs).group(1)
'+911234567890'
>>> 
于 2013-06-03T07:04:42.353 回答
1

如果数字始终是第 n 个字段,则:

s = '+CMGR: "REC READ","+911234567890",,"13/05/31,10:00:14+22"'
import csv
print next(csv.reader([s]))[1]
# +911234567890
于 2013-06-03T07:20:50.253 回答