['#', 'vcrisan', '#sses', '#crusu', 'ALL', '#rpavlicek', 'oracle', '#vcrisan', 'dwilks,skumar', 'sjoshi,skekes', 'skekes', 'sdammalapati', 'sdammalapati']
I am trying to remove string with # in the list and if the string is like 'dwilks,skumar' will split it again and add to the string again removing the old one.
我使用的条件是工作,但只有一次
for name in userslist:
if '#' in name:
userslist.remove(name)
if ',' in name:
newwlist=name.split(',')
userslist.remove(name)
for splittedname in newwlist:
userslist.append(splittedname)
print (userslist)
结果:
['vcrisan'、'crusu'、'ALL'、'oracle'、'dwilks、skumar'、'skekes'、'sdamalapati'、'sdamalapati'、'sjoshi'、'skekes']
它适用于前两个#散列,而不适用于第三个#散列同样适用于逗号大小写它适用于第二个值sjoshi,skekes only
注意: 请不要推荐re模块
这也许对你有帮助
相关问题 更多 >
编程相关推荐