如何使IDLE在启动时自动导入模块?

问题描述 投票:2回答:1

[通常,当我使用IDLE shell时,我会导入pickle模块。启动时是否可以使其自动导入pickle

python python-import python-idle autostart
1个回答
1
投票

您可以使用-c或-r参数:

来自idle -h

-c cmd     run the command in a shell, or
-r file    run script from file

例如:

idle -c 'import pickle, sys'

或:

idle -r ~/my_startup.py

my_startup.py可能包含:

import pickle, sys

您可以创建shell别名以始终使用它,也可以创建单独的脚本;根据您的操作系统和外壳,此过程有所不同。

© www.soinside.com 2019 - 2024. All rights reserved.