我有我的
datacount= ([('mark / 222696_at', 19), ('jason / 210393_at', 15), ('mickey / 213880_at', 15), ('mo / 228649_at', 13), ('nick / 229481_at', 12), ('nikoo / 1553115_at', 12), ('- / 229613_at', 12)]
但是我想删除列表中的元组,它以“-/2”开头,比如('-/229613_at',12)。在
我试过了
^{pr2}$但是,诸如('-/229613'u at',12),('-/232203'u at',11)、('-/244174_at',6)、('-/237146_at',6)的结果仍然存在。在
试试这个:
不完全确定您用
x[0] not in ['str.startwith(- / 2) == True']
尝试了什么,但它看起来像是其他语言中可能出现的某种模式。在Python中,这实际上检查x[0]
是否等于字符串'str.startwith(- / 2) == True'
。在你离得不远了。在
in
检查中,你似乎对所发生的事情有一个错误的心理模型。在我建议以下列表理解,以解包元组以获得更好的易读性为特点(而不是
x[0]
索引):相关问题 更多 >
编程相关推荐