How do I change the working directory in Python?

前端 未结 14 1172
天涯浪人
天涯浪人 2020-11-22 01:59

cd is the shell command to change the working directory.

How do I change the current working directory in Python?

14条回答
  •  长发绾君心
    2020-11-22 02:26

    I would use os.chdir like this:

    os.chdir("/path/to/change/to")
    

    By the way, if you need to figure out your current path, use os.getcwd().

    More here

提交回复
热议问题