As I open IDLE, how do I know my current working directory? And how to change to another working directory?
How To
1. you need to import os module first
2. use os.getcwd() to get current working directory
3. use os.chdir("XXX") to change working directory
1 2 3 4 5 6 7 8 9 | Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import os >>> os.getcwd() 'C:\\Users\\albert\\AppData\\Local\\Programs\\Python\\Python35-32' >>> os.chdir("D:\python") >>> os.getcwd() 'D:\\python' >>> |
Reference
[1] http://stackoverflow.com/questions/15821121/whats-the-working-directory-when-using-idle
No comments:
Post a Comment