我遇到了一个奇怪的问题"使用我的程序...当我运行它时,选择第二个选项并输入" list"我的计算机跳了起来,发生了这种情况:
List:
1 = ☺
2 = ☻
3 = ♥
4 = ♦
5 = ♣
6 = ♠
7 =
8 =
9 =
10 =
11 = ♂
12 = ♀
13 =
14 = ♫
15 = ☼
这是我的代码:
#In This Program We Will Be Converting ASCII To It's Numerical Counterpart And Visa-Versa...
no = 0
on = 0
lo = 0
ol = 0
print ("Welcome to the ASCII/Numerical-Counterpart Converter!\nPlease Select One Of The Following:\n1: ASCII to Number.\n2: Number to ASCII")
inp = raw_input(":")
if inp == "1":
inp1 = raw_input("Please Enter ASCII Character(s)\n:")
no = len(inp1)
while no != on:
print inp1[on], "=", ord(inp1[on])
on += 1
exit()
if inp == "2":
inp2 = raw_input("Please Enter Numerical Character(s), or \"list\" (Use Spaces For Multiple Integers)\n:")
wall = ""
if inp2 == "list":
print "\nList:"
al = 1
do = 128
inp2 = ""
while do != al:
wall = str(al)
if al == 127:
inp2 += wall
else:
inp2 += wall + " "
al += 1
lo = inp2.split(" ")
loo = len(lo)
while loo != ol:
out = lo[ol]
outie = int(out)
if outie > 127:
print "Sorry! Can't Convert Numbers Larger Than 127..."
exit()
print lo[ol], "=", str(unichr(outie))
ol += 1
如果有人能告诉我它为什么要这样做,我会非常感激......我不知道发生了什么......
答案 0 :(得分:0)
10的ASCII字符是LineFeed。因此,它会显示为新行,您可以在输出中看到。
答案 1 :(得分:0)
32以下的ASCII字符具有特殊含义:ASCII 7是" bell"字符(显示为蜂鸣声),ASCII 9是制表符,ASCII 10是换行符,ASCII 13是回车符。有关详细信息,请参阅Wikipedia。