推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
bestehen
V2EX  ›  Python

Python 中的 pathlib 怎么用

  •  
  •   bestehen · Sep 2, 2018 · 3111 views
    This topic created in 2830 days ago, the information mentioned may be changed or developed.

    Path('/home/stephen/shenjianlin') PosixPath('/home/stephen/shenjianlin') Path('/home/stephen/shenjianlin').parent PosixPath('/home/stephen') 这里我要的是路径 怎么有 PosixPath 这种东西出来?难道要正则处理?

    matrix273
        1
    matrix273  
       Sep 2, 2018 via Android
    str(Path())
    Path().stem
    Path().name
    HelloAmadeus
        2
    HelloAmadeus  
       Sep 2, 2018
    因为你在 posix 兼容的系统啊, Path 类是一个接口, posixpath 类是具体实现, 你用就行了
    inframe
        3
    inframe  
       Sep 2, 2018 via Android
    读一读 官方的帮助文档
    写得很清楚的
    bestehen
        4
    bestehen  
    OP
       Sep 2, 2018
    @matrix273 解决了谢谢
    bestehen
        5
    bestehen  
    OP
       Sep 2, 2018
    @inframe 你说的官方文档是那个 piyi 的 homepage 吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4865 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 93c8b4a0 · 49ms · UTC 01:06 · PVG 09:06 · LAX 18:06 · JFK 21:06
    ♥ Do have faith in what you're doing.