c = list(range(97, 121))
如果我打印它会给出 [97,98,99,10,10,101,103,103,104,106,107,108,109,110,111,112,113,114,115,116,117,118,119]
这些数字中的每一个chr()字符串只是字母表,但是当我打印c时如何将此列表转换为字母表
c = list(range(chr(97),chr(121)))
给出错误。所以不确定如何一次性转换它们而不是单独进行转换
感谢
答案 0 :(得分:2)
你应该使用列表理解
c = [chr(i) for i in range(97, 121)]
答案 1 :(得分:1)
intlist = [97,98,99,100,101,102,103,104,105,106]
charlist = [chlist(x)for x in intlist]
答案 2 :(得分:0)
intList = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106]
charList = [chr( intList[i] ) for i in range( 0, len( intList ) )]
答案 3 :(得分:0)
intList = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106]
charList = [chr(c) for c in intList]
string = "".join(charList)