我想从Unicode列表中移除特定值,即field
u'abv,( field),apn,army,elev,fema'
但是当我尝试类似result.remove ('(field)')
之类的东西时,它会停止工作并发出错误吗?
答案 0 :(得分:3)
将其转换为列表并使用remove
s = u'abv,( field),apn,army,elev,fema'
res = s.split(",")
res.remove("army") # lets assume we need to remove army
['abv', '( field)', 'apn', 'elev', 'fema']
如果您愿意,也可以将输出列表恢复为字符串
output = ",".join(res)
'abv,( field),apn,elev,fema'