参考:
https://blog.csdn.net/lhkuxia/article/details/123727389
将键盘码转为字符:
c
keyboard_code = "63" # 键盘码(不带问号)
character = chr(int(keyboard_code)) # 将键盘码转换为字符
print("键盘码带问号后的结果:", character)
将大写字母转为小写字母:
c
# 接收键盘输入并转换成小写字母的ASCII码
input_char = input("请输入一个小写字母:")
ascii_code = ord(input_char) - 32 # ASCII码值加上32得到大写字母的ASCII码
print("该小写字母的ASCII码为:", ascii_code)
通过qt确认特殊按钮键盘码:
c
if key == Qt.Key_Shift:
return KeyEvent.ShiftKey
elif key == Qt.Key_Control:
return KeyEvent.ControlKey
elif key == Qt.Key_Alt:
return KeyEvent.AltKey
elif key == Qt.Key_Space:
return KeyEvent.SpaceKey
elif key == Qt.Key_Meta:
return KeyEvent.MetaKey
elif key == Qt.Key_Enter or key == Qt.Key_Return:
return KeyEvent.EnterKey
elif key == Qt.Key_Up:
return KeyEvent.UpKey
elif key == Qt.Key_Down:
return KeyEvent.DownKey
elif key == Qt.Key_Left:
return KeyEvent.LeftKey
elif key == Qt.Key_Right:
return KeyEvent.RightKey
elif key == Qt.Key_Minus:
return KeyEvent.MinusKey
elif key == Qt.Key_Underscore:
return KeyEvent.UnderscoreKey
elif key == Qt.Key_Plus:
return KeyEvent.PlusKey
elif key == Qt.Key_Equal:
return KeyEvent.EqualKey