问题
Often when I am using the IDLE shell I import the pickle
module. Is it possible to make it automatically import pickle
when I start it?
回答1:
You can use the -c
or -r
argument:
From idle -h
:
-c cmd run the command in a shell, or
-r file run script from file
For example:
idle -c 'import pickle, sys'
Or:
idle -r ~/my_startup.py
Where my_startup.py
might contain:
import pickle, sys
You can either create a shell alias to always use this, or create a separate script; the procedure for this differs depending on your OS and shell.
来源:https://stackoverflow.com/questions/25603955/how-to-make-idle-automatically-import-modules-at-start