美文网首页
Python生成[a-z]列表的两种方法 by L0st

Python生成[a-z]列表的两种方法 by L0st

作者: l0st | 来源:发表于2018-11-07 16:57 被阅读0次

自己写个列表:

letter_list = ['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']

使用ascii码:

python中 chr(数字) 会将转换为ascii码对应的字符,ord()则相反。

for letter in range(65,91):
     print(chr(letter))

相关文章

网友评论

      本文标题:Python生成[a-z]列表的两种方法 by L0st

      本文链接:https://www.haomeiwen.com/subject/ddivxqtx.html