[英]python : an integer is required (got type str)
I just need to print a list of int to ASCII.我只需要将 int 列表打印为 ASCII。
a=list(str(12345))
for q in a:
print(chr(q))
an integer is required (got type str)
需要一个整数(得到类型 str)
why I'm getting that error?为什么我收到那个错误?
You are passing a string value into the chr() function.您正在将字符串值传递给 chr() 函数。 This should work:
这应该有效:
a=list(str(12345))
for q in a:
print(chr(int(q)))
#The above code will work but this will print out characters, as 1-5
# in the ASCII table are not visible characters.
a = [65,66,67,68,69]
for q in a:
print(chr(q))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.