Python 获取当前路径 - os.getcwd() 使用方法
在 Python 中,可以使用 'os' 模块的 'getcwd()' 函数来获取当前路径。示例代码如下:
import os
current_path = os.getcwd()
print('当前路径为:', current_path)
运行结果类似于:
当前路径为: C:\Users\username\Documents
请注意,当前路径是指运行 Python 脚本时所在的路径。
原文地址: https://www.cveoy.top/t/topic/cgv0 著作权归作者所有。请勿转载和采集!