Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ValueError:chr()参数不在范围内(0x110000)_Python - Fatal编程技术网

Python ValueError:chr()参数不在范围内(0x110000)

Python ValueError:chr()参数不在范围内(0x110000),python,Python,编写一个解码程序,并继续运行到 ValueError:chr()参数不在范围内(0x110000) 当我输入字符串时,我需要解码。输入字符串为: [2ea^W_`^k2eiWSd2fZSf2[2S_2gb2fa2`a2YaaV@ 目前代码如下: # String manipulation # This program accepts a string and an integer # then decodes the number of lines by a know decryption k

编写一个解码程序,并继续运行到

ValueError:chr()参数不在范围内(0x110000)

当我输入字符串时,我需要解码。输入字符串为:

[2ea^W_`^k2eiWSd2fZSf2[2S_2gb2fa2`a2YaaV@
目前代码如下:

# String manipulation
# This program accepts a string and an integer
# then decodes the number of lines by a know decryption key

# Initialize the program and necessary variable
print("This progam can decode an encrypted by a known encryption key")
string=""
decoded_message=""
coded_message=""

# Prompting the used for input using a for loop to accept multiple lines
coded_message=input("What is the line to be decoded?")

# Using a for loop, the messges will be decrypted character
# at at time to its ASCII value then decrypted and converted
# back to text
for string in coded_message:
    converted_text=ord(string)
    decryption=(chr(converted_text-18))
    decoded_message+=decryption
# Output the decoded message
print("Your decrypted message is:",decoded_message)

我确信我遗漏了一些简单的东西,但任何帮助都会很好

也许当你从原始ascii值中减去18时,它超出了范围,即小于0。

结果表明这就是问题所在。我们要测试的信息中有一个不应该存在的空间。