【发布时间】:2019-04-08 08:22:45
【问题描述】:
我有一个包含用户信息的 csv 文件。该文件的示例如下。
"userType": "NORMAL", "accountID": "J123456789"
"userType": "NORMAL", "accountID": "J987654321"
"userType": "NORMAL", "accountID": "C123456789"
"userType": "NORMAL", "accountID": "R987654321"
我想在 python 3 中使用正则表达式获取 id 号。
我使用的正则表达式是("accountID": ")\w+,它会生成以下结果。
"accountID": "J123456789
"accountID": "J987654321
"accountID": "C123456789
"accountID": "R987654321
所需的输出应如下所示,
J987654321
J987654321
C123456789
R987654321
【问题讨论】:
-
使用
"accountID": "(\w+)和re.findall -
为了感兴趣,请:为什么这个任务需要
re? -
如果你有
"accountID": "J123456789",你怎么会期待J987654321?
标签: python regex python-3.x