选择频道搜索
在Python中,可以使用os模块中的getcwd()函数来获取当前工作目录。getcwd()函数不需要任何参数。示例如下:
os
getcwd()
import os# 获取当前工作目录current_dir = os.getcwd()print("当前工作目录:", current_dir)
输出结果为当前工作目录的路径。