您好我是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)
但这只取%年龄值