while True:
cmd = input('>>> ')
last = cmd[-1]
while last == ':' or last == '\\':
temp = input('... ')
cmd += temp
last = cmd[-1]
try:
res = eval(cmd)
print(res)
except BaseException as e:
try:
exec(cmd)
except BaseException as e:
print(e)
Python15行代码实现简易交互式命令行
最新推荐文章于 2022-09-22 00:55:10 发布