Is there a built in list in python or some package that has a list of the alphabets? I would like to avoid a system such as
alphabets = ('a','b','c',.....)
Is there a built in list in python or some package that has a list of the alphabets? I would like to avoid a system such as
alphabets = ('a','b','c',.....)
>>> from string import ascii_lowercase
>>> ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
>>> list(ascii_lowercase)
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
您还可以进行列表理解:
>>> [chr(i) for i in range(97,97+26)]
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']