【问题标题】:How to find document directory programatically - Pythyon如何以编程方式查找文档目录 - Python
【发布时间】:2020-04-06 12:30:37
【问题描述】:

我需要使用 pyhon 以编程方式查找默认的“文档”目录路径

import os

print(os.getcwd())

我可以使用上面的代码访问当前目录。如何获取默认的“Document”目录。

【问题讨论】:

标签: python directory path document


【解决方案1】:
os.path.expanduser("~/Documents")

这样应该可以实现你想要的。

更多文档可以参考https://docs.python.org/2/library/os.path.html

【讨论】:

    猜你喜欢
    • 2017-04-27
    • 2011-09-28
    • 2010-09-18
    • 1970-01-01
    • 2010-09-28
    • 2011-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多