能不能用python的函数将26个英文字母赋值给一个列表?
答案:3 悬赏:20
解决时间 2021-02-14 15:42
- 提问者网友:騷女、無惡不作
- 2021-02-14 02:37
能不能用python的函数将26个英文字母赋值给一个列表?
最佳答案
- 二级知识专家网友:啵啵桃汀
- 2021-02-14 02:55
import string
wList = []
for word in string.lowercase:
wList.append(word)
print wList
#['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']
wList = []
for word in string.lowercase:
wList.append(word)
print wList
#['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']
全部回答
- 1楼网友:闲懒诗人
- 2021-02-14 03:33
import string
wordList = list(string.ascii_lowercase)
- 2楼网友:陪伴是最长情的告白
- 2021-02-14 03:12
>>> list(map(chr, range(ord('a'), ord('z') + 1)))
['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(x) for x in range(ord('a'), ord('z') + 1)]
['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']以上是python3代码
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯