小编aqo*_*oon的帖子

正则表达式在python中分割%年龄和值

您好我是python和regex的新手.我有一个大的CSV文件,其中%age composition包含类似的字段,其中包含以下值:

'34% passed 23% failed 46% deferred'

如何拆分此字符串以便获取字典对象:

{'passed': 34, 'failed': 23, 'deferred': 46} 每排?

我试过这个:

for line in csv_lines:
    for match in re.findall('[\d\s%%]*\s', line)
Run Code Online (Sandbox Code Playgroud)

但这只取%年龄值

python regex

0
推荐指数
1
解决办法
171
查看次数

标签 统计

python ×1

regex ×1