我有一个我正在尝试执行的 python 脚本,但我不确定它是如何执行的。我不会用 Python 编程,所以我不熟悉这门语言。 Here is the link to the script i'm trying to use.还有一个 link the configuration it's using if you wish to see it.然而,似乎与此处相关的所有内容都是设置我的路径,我知道这是正确的,因为其他脚本(此处未链接)与该文件中的配置按预期工作。
看看脚本,我相信脚本应该使用命令行参数运行:view、new、init。因此,我在终端中运行了以下内容
$ lectures.py new
但我得到以下回溯
Traceback (most recent call last):
File "/usr/bin/lectures.py", line 156, in <module>
lectures = Lectures(Path.cwd())
File "/usr/bin/lectures.py", line 60, in __init__
self.root = course.path
AttributeError: 'PosixPath' object has no attribute 'path'
此外,我的python版本
$ python --version
Python 3.8.1
编辑:
I wanted to add the reference as well for what I am trying to follow
最佳答案
通过你的代码,我想你的意思可能是:
self.root = course
在那条线上。
Path.cwd()
返回:... the current working directory, that is, the directory from where you run the script.
也就是说,要么是
WindowsPath()
或 PosixPath
目的。我相信是PosixPath
为您,您可以验证:import os
print(os.name)
# posix -> Linux
# nt -> Windows
这没有属性
path
,这就是你的口译员告诉你的。
关于python - 属性错误 : 'PosixPath' object has no attribute 'path' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59693174/