我有一个列表列表:
data = [['SiteUrl','Url','Title'],['SiteUrl','Url','Title']]
如何使用 python 遍历列表并将所有内容小写?
最佳答案
使用列表理解:
data = [[x.casefold() for x in sublst] for sublst in data]
或者功能上:
data = [list(map(str.casefold, x)) for x in data]
来自 the docs :
Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string.
关于python - 小写列表列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54438770/