Python中文
首页
教程
问答
标签
搜索
登录
注册
Pythons的AttributeError:“NoneType”对象没有属性“errors”
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我知道它已经在这里很多次了,但我没有找到我的案件的正确答案。<br/> <strong>首先:</strong>我正在制作一个简单的数据库系统(对我自己来说),它将不使用散列等(至少现在是这样)。现在我被卡住了。</p> <pre><code>import sys import os filename = "" database = "" path = "" table = "" class Nollty: returns = 0 errors = 0 def __init__(self, filename, database): self.filename = filename self.database = database self.path = self.filename + "databases/" + self.database openfile = open(self.path + "/db_required", "r") if not openfile.errors: self.returns = 1 if not os.path.exists(self.path + "/db_required"): self.returns = 0 openfile.close(); def select(self, table): errors = 0 self.table = table openfile = open(self.path + "/" + self.table, "r") if not openfile.errors: errors = 1 if not os.path.exists(self.path + "/" + self.table): errors = 0 openfile.close(); nollty = Nollty("", "test") if nollty.returns == 1: print "Successfully connected to the database!" query = nollty.select("aaa_auto") if query.errors == 0: print "Successfully chosen the table!" </code></pre> <p>错误输出为:</p> <pre><code>Traceback (most recent call last): File "/home/spotrudloff/Python/Nollty/nollty.py", line 40, in <module> if query.errors == 0: AttributeError: 'NoneType' object has no attribute 'errors' </code></pre> <p>问题可能是我是一个PHP程序员,我今天只花了几个小时就学会了Python(所以我的想法还是“PHPy”)。</p> <p>谢谢你的回复。</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>看起来select()没有返回值,所以它默认为NoneType(null)。或者(您可能打算这么做),将query更改为nollty。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
jupyter运行一个旧的pytorch版本
8 回答
Jupyter运行不同版本的卸载库?
8 回答
Jupyter运行指定的键盘快捷键
3 回答
Jupyter通过.local文件“逃逸”virtualenv。我该如何缓解这种情况?
4 回答
Jupyter重新加载自定义样式
10 回答
Jupyter错误:“没有名为Jupyter_core.paths的模块”
6 回答
jupyter错误:无法在随机林中将决策树视为png
5 回答
Jupyter错误'内核似乎已经死亡,它将自动重新启动'为一个给定的代码块
5 回答
Jupyter错误地用阿拉伯语和字母数字元素显示Python列表
5 回答
Jupyter隐藏数据帧索引,但保留原始样式
7 回答
Jupyter集线器:启动器中出现致命错误。。。系统找不到指定的文件
7 回答
Jupyther中相同值的相同哈希,但导出到Bigquery时不相同
10 回答
Jupy上Python的读/写访问问题
7 回答
jupy上没有模块cv
7 回答
Jupy上的排序错误
3 回答
Jupy中bqplot图形的紧凑布局
7 回答
Jupy中matplotlib plot的连续更新
6 回答
Jupy中Numpy函数的文档
10 回答
Jupy中Pandas的自动完成问题
8 回答
jupy中Qt后端的Matplotlib动画
4 回答