如何在Python中设置当前工作目录?

您可以使用os模块在Python中更改目录或cd。它以您要切换到的目录的相对/绝对路径作为输入。

例如

>>> import os
>>> os.chdir('my_folder')