我有一些 Python 代码行,我不断地将它们复制/粘贴到 Python 控制台中。是否有 load
命令或我可以运行的东西?例如加载文件.py
最佳答案
来自手册页:
-i When a script is passed as first argument or the -c option is used, enter interactive mode after executing the script or the command. It does not read the $PYTHONSTARTUP file. This can be useful to inspect global variables or a stack trace when a script raises an exception.
所以这应该做你想要的:
python -i file.py
关于python - 如何将文件加载到 python 控制台中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5280178/