比如:['tu=d37b3e79010b526f853a69732e5d9600;Path=/uipp', 'cmddl=1f37cdb7dbb39d487ed7ae456241d71c;Path=/kl', 'popod_=e910be433b4e6;Path=/ffg'],这个列表,我需要一次性去除;后面的内容,应该怎么办?
1条回答 默认 最新
threenewbee 2019-06-18 21:44关注不知道你说的后面的内容是什么内容,哪里是后面
你可以用 re.sub(正则,替换的内容因为你是去掉这里写两个单引号,原始字符串)# -*- coding: UTF-8 -*- import re list = ['tu=d37b3e79010b526f853a69732e5d9600;Path=/uipp', 'cmddl=1f37cdb7dbb39d487ed7ae456241d71c;Path=/kl', 'popod_=e910be433b4e6;Path=/ffg'] list1 = map(lambda x : re.sub(";Path=[^\']+", '', x), list) print(list1)['tu=d37b3e79010b526f853a69732e5d9600', 'cmddl=1f37cdb7dbb39d487ed7ae456241d71c', 'popod_=e910be433b4e6']
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 2无用