[In site.py] an attempt is made to import a module named sitecustomize, which can perform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages directory. If this import fails with an ImportError exception, it is silently ignored.
定义一个
PYTHONSTARTUP
环境变量并将其指向一个python文件,当您不使用命令行脚本以交互方式启动python时,它将被加载。我的
PYTHONSTARTUP
指向一个.pythonrc
,我试图在当前目录中为任何交互式python会话导入__boot__.py
(引导)。在我的pythonrc中还有很多其他东西,比如
__future__
导入、readline设置等等一个选项是将导入添加到
sitecustomize.py
。此文件在启动时自动导入。无论Python是否以交互模式启动,都将加载该文件。引用docs:另一个选项是在导入时将
PYTHONSTARTUP
环境变量设置为启动脚本。不过,如果Python只在交互模式下执行,那么Python将只在交互模式下启动。在如果你的意思是在进入交互模式时,只需制作一个小的启动脚本。而不是仅仅通过以下方式启动python:
试试看:
^{pr2}$在startupImports.py公司名称:
相关问题 更多 >
编程相关推荐