os.chdir(path)
path -- 這是被用來改變到一個新的位置的完整路徑目錄。
#!/usr/bin/python3 import os path = "d:\\python3" #change path for linux # Now change the directory os.chdir( path ) # Check current working directory. retval = os.getcwd() print ("Directory changed successfully %s" % retval)
Directory changed successfully d:\python3