So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can check that using
os.getcwd()
:os.chdir()
:os.getcwd()
:Here is an excerpt from usfca.edu
You can easily check that yourself using
os.getcwd
:That’s on my Windows machine, so it’s probably the installation directory of Python itself.
You can change that directory at runtime using
os.chdir
:This will—not surprisingly—create the file on my desktop.
This will depend on OS and how IDLE is executed.
To change the (default) CWD in Windows, right click on the Short-cut Icon, go to "Properties" and change "Start In".