开发者

Python: changing IDLE's path in WIN7 [duplicate]

This question already has answers here: How to know/change current directory in Python shell? 开发者_开发问答 (7 answers) Closed 9 years ago.

Windows 7 As I'm learning Python (3.2) I prefer using IDLE than CMD. In order to change the path where I can import scripts of my own, I use a little trick that I found in this site: I go FILE>OPEN>directory>myscript and then run it and from then on I'm on this directory.

Nevertheless, I wonder whether there is a simple command, like CD... to move to the correct directory, without using tricks.

Thank you,


http://www.skylit.com/python/Appendix-A.html

Check section A.2, just before section A.3:

>>> from os import chdir
>>> chdir("C:/myOtherWork")

And also to check the working directory:

>>> from os.path import abspath
>>> abspath('.')

If the current directory is not already in the path you need to add it:

>>> import sys
>>> sys.path.append('.')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜