首页 > 代码库 > pyqt字符串分离开,放入列表中

pyqt字符串分离开,放入列表中

string1 = ‘‘‘‘‘
the stirng
Has many
line In
THE fIle
‘‘‘
list_of_string = string1.split()
print list_of_string #将字符串分离开,放入列表中
print ‘*‘*50


def case_insensitive_sort(liststring):
listtemp = [(x.lower(),x) for x in liststring]
listtemp.sort()

return [x[1] for x in listtemp]

print case_insensitive_sort(list_of_string)
def case_insensitive_sort2(liststring):
return sorted(liststring,key = str.lower)
if __name__==‘__main__‘:
print case_insensitive_sort2([‘c‘,‘a‘,‘1‘,‘.‘])