How to make IDLE automatically import modules at start?

老子叫甜甜 提交于 2021-01-27 17:51:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!