python怎么去读取一个单元格内用逗号隔开的多个内容
如上图想要读取Seq键值对应该如何处理
请看 https://blog.csdn.net/lucky_shi/article/details/105321149
有多种方法可以读取,如要处理的行数据为t:
1.正则表达式
import re
result=re.search('Seq=(.*)',t).group()
2.索引
result = t[t.index('Seq'):t.index('Seq')+9]
3.列表表达式
result=[ x for x in t.split(',') if 'Seq' in x][0]
如需结果为字典形式,{result.split('=')[0]:result.split('=')[-1]},获取想要的键值对。
如只想获取Seq的值,分别修改为:result=re.search('Seq=(.*)',t).group(1),t[t.index('Seq')+4:t.index('Seq')+9],[ x.split('=')[1] for x in t.split(',') if 'Seq' in x][0],