Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我会将路径形式 pathlib 添加到我的 vscode 但每当我调用它的模块时,例如 path.stat 我有一个错误,并且 vscode 不允许我使用 () 来调用
from pathlib import Path path=Path("enum/__init__.py") pri=path.stat print(pri)
错误是:绑定方法 Path.read_bytes of WindowsPath('enum/ init .py')
Unix 系统在文件名中使用斜杠作为分隔符 ( / )。 在 Microsoft Windows 上使用反斜杠 ( \ )。 因此,您的代码应编辑如下:
from pathlib import Path path=Path(r"enum\__init__.py") pri=path.stat print(pri)