首页 > 解决方案 > 溢出错误:字符参数不在范围内(0x110000)在 python 3.5 中使用 getch

问题描述

我在 ubuntu 中使用 getch 得到溢出错误。这是代码:

import getch
print("Inserisci 8 caratteri esadecimali: ")
allowedChar = '0123456789abcdefABCDEF'
contatore = 0
uuid = ""
while contatore < 8:
    char = getch.getch()  # User input, but not displayed on the screen
if char in allowedChar:
    print(char, end="", flush=True)
    contatore = contatore + 1
    uuid = uuid + char
uuid = uuid + "-"
print(uuid)

我必须输入一个 UUID,但我只想显示允许的字符(十六进制数字),但是当我输入“è”或“ù”或“ò”或“à”时,我收到此错误:

Traceback (last recent call last): File "Char.py", line 7, in char = getch.getch() # 用户输入,但未显示在屏幕上 OverflowError: character argument not in range(0x110000).

请我需要克服这个错误。我需要帮助。我没有使用 Windows。

标签: python-3.xubuntu-16.04getch

解决方案


推荐阅读