我有一个这样的字典列表:
myList = [
{
'id':1,
'text':['I like cheese.',
'I love cheese.', 'oh Ilikecheese !'],
'text_2': [('david',
'david',
'I do not like cheese.'),
('david',
'david',
'cheese is good.')]
},
{
'id':2,
'text':['I like strawberry.', 'I love strawberry'],
'text_2':[('alice',
'alice',
'strawberry is good.'),
('alice',
'alice',
' strawberry is so so.')]
}
]
我想删除长度超过一定数量的字母(例如9个字母)的单词
理想的输出是相同的词典列表,但删除拼写错误的单词,如删除“Ilikecheese”:
myList = [
{
'id':1,
'text':['I like cheese.',
'I love cheese.', 'oh!'],
'text_2': [('david',
'david',
'I do not like cheese.'),
('david',
'david',
'cheese is good.')]
},
{
'id':2,
'text':['I like strawberry.', 'I love strawberry'],
'text_2':[('alice',
'alice',
'strawberry is good.'),
('alice',
'alice',
' strawberry is so so.')]
}
]
有什么建议吗
删除长度大于或等于9的字符串中的每个单词。分割字符串的标准:单个空格
输出
如果是
tuple
而不是lists
相关问题 更多 >
编程相关推荐