Skip to main content
 首页 » 编程设计

python之如何将列表列表中的元素转换为小写

2025年05月04日9rubylouvre

我正在尝试将列表中的元素转换为小写。这就是它的样子。

print(dataset) 
[['It', 'went', 'Through', 'my', 'shirt', 'And', 'came', 'out', 'The', 'back', 'and', 'hit', 'the', 'kid', 'behind', 'me', 'in', 'the', 'toe']] 

我试过这样做:

for line in dataset: 
    rt=[w.lower() for w in line] 

然而,这给了我一个错误,说列表对象没有属性 lower()。