gpt4 book ai didi

python - 如何将文件加载到 python 控制台中?

转载 作者:IT老高 更新时间:2023-10-28 12:20:21 27 4
gpt4 key购买 nike

我有一些 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com