# coding:utf-8
#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
print("Hello world! - python.jsrun.net .")
import sys
def getch():
"""获取单个字符输入,不需要回车(跨平台版)"""
try:
# Windows系统使用msvcrt
import msvcrt
return msvcrt.getch().decode('utf-8')
except ImportError:
# 非Windows系统使用termios和tty
import tty
import termios
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setcbreak(fd)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
# 使用示例
print("请输入一个字符(无需回车):")
char = getch()
print(f"\n你输入的是:{char}")