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