Get and Change Current Folder Path in Python

May. 23, 2024

1
import os

Get current folder path using os.getcwd() method:

1
os.getcwd()

Change current folder path using os.chdir method:

1
os.chdir($PATH)

NOTE THAT the path separator in $PATH is \\, rather than \.


References

[1] spyder的工作路径和python的搜索路径.