【发布时间】:2021-02-26 04:41:24
【问题描述】:
所以我在搞乱python的“cmd”模块,我想要一个可以输入“python”的命令,然后它会打开一个python命令行。有点像实际的命令行。
这是我当前的代码。
import cmd
class pythonCmd(cmd.Cmd):
def do_(self, args): # <--- I want this command to have it so you don't type a key word
exec(args)
class cmdLine(cmd.Cmd):
def do_python(self, args):
prompt = pythonCmd()
prompt.prompt = 'python> '
prompt.cmdloop('Python 3.8.2')
prompt = cmdLine()
prompt.prompt = '> '
prompt.cmdloop('Command line starting . . .')
【问题讨论】:
标签: python