我正在编写一个带有定义函数的猜谜游戏程序。它要求用户想出一个介于1到1000之间的数字,然后程序试图在不到15次尝试中猜出这个数字。对于我的函数,为了在每个函数中返回多个值,我将它们作为列表返回。但是有一个NoneType错误--这是错误消息。
Traceback (most recent call last):
File "python", line 187, in <module>
File "python", line 167, in main
TypeError: 'NoneType' object is not su
当我的(python2.7)程序退出时,我得到了许多被忽略的异常。但是由于项目规模很大,而且是基于别人开发的项目,所以很难用这样的信息来定位bug。有没有办法获得异常跟踪,或任何其他方法,可以帮助?谢谢。
Exception TypeError: "'NoneType' object is not callable" in <object repr() failed> ignored
Exception TypeError: "'NoneType' object is not callable" in <obje
import csv
from geopy import geocoders
import time
g = geocoders.GeocoderDotUS()
spamReader = csv.reader(open('locations.csv', 'rb'), delimiter='\t', quotechar='|')
f = open("output.txt",'w')
for row in spamReader:
a = ', '.join(row)
#exact
我在下面的代码片段中得到了这个错误。我正在计算图像的嵌入。
----> 4 img = load_image(m.image_path())
5 img = align_image(img)
6 # scale RGB values to interval [0,1]
<ipython-input-14-23aefaa58a32> in load_image(path)
12 # in BGR order. So we need to reverse them
13 #destRGB = c
我正在编写一个数学小程序(没有特别的原因,只是有点想这样做),我遇到了错误"TypeError:'NoneType‘对象不可订阅。
我以前从未见过这个错误,所以我不知道它是什么意思。
import math
print("The format you should consider:")
print str("value 1a")+str(" + ")+str("value 2")+str(" = ")+str("value 3a ")+str("value 4")
def get_coffee_name(coffee_type):
if coffee_type == "Hot":
conn = sqlite3.connect('coffee.db')
c = conn.cursor()
coffee_id = rand_coffee()
c.execute("SELECT tag FROM coffees WHERE id = '%s'" % (coffee_id))
while True:
以下代码:
a = None
b = None
all([a, b, a > b]) # Returns False in python 2 but TypeError in python 3
python 3中的错误:
TypeError: '>' not supported between instances of 'NoneType' and 'NoneType'
看起来python 2版本是短路版,而python 3版本则不是。是这种情况吗?为什么会发生这种情况?是虫子吗?要我报告吗?
我在Python2.7.17、3.6.9
我正在做一个小函数,它应该按照姓氏的字母顺序对学位进行排序(“如果两个人的姓氏相同,也可以使用名字),并且我堆叠了错误"TypeError:'NoneType‘对象不可订阅。
我以前从未见过这个错误,所以我不知道它是什么意思。
def degreescheem(listing,x):
printed=False
temporlist=[]
for i in listing:
if i[3] == x :temporlist.append(i)
slist=sorted(temporlist,key=lambda s:(s[4],s[5]))
for j in slist :
我有一个超过2000行的python脚本,它是通过生产服务器上的以下异常处理的,我不能在本地重现这个问题来调试它,我也不知道它是从哪里来的。
Exception TypeError: TypeError("argument of type 'NoneType' is not iterable",) in <bound method Popen3.__del__ of <popen2.Popen3 instance at 0x7fccba7b65f0>> ignored
Exception TypeError: TypeError("
我不明白这有什么不对。我怎么才能修好它?
for users in ctx.guild.members:
winner = random.choice(users)
await channel.send(f"Congratulations! {winner} won {prize}!")
回溯:
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in command giveaway:
Traceback (most r
我在做py4e作业5.2。在浏览器中,输入我的代码时一切正常,但是当我尝试使用CMD时,代码不能工作,给出错误:“TypeError:‘不支持'int’和‘NoneType’之间的实例”
largest = None
smallest = None
while True:
sval = input("enter a number ")
if sval=="done":
break
try:
fval = int(sval)
except:
print("Invalid
我尝试在一个方法中使用计时器,作为等待一段时间的方式,而不会阻塞脚本,就像time.sleep那样。 在类外部,计时器代码运行良好,但在类方法内部,它返回错误: TypeError:'NoneType‘对象不可调用 import time
from threading import Timer
openDuration = 10
### Valve class
class Valve():
def open(self, openDuration):
t = Timer(openDuration, Valve().dummyWait())
当我试图传递“但不是”如果最大< num:“我得到"TypeError:'<‘NoneType’和‘int’的实例之间不受支持。这意味着我不能比较NoneType和整数。但是,”如果最大是无或最大< num:“的情况不是仍然是这样吗?
largest = None
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try:
将None传递给Python的list构造函数是一个TypeError
>>> l = list(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable
但是,使用方括号实例化list是很好的;在内置函数中使用None也很好:
>>> l = [None]
>>> l.append(None)
&
if story['epic']['id'] == epic['id']:
TypeError: 'NoneType' object is not subscriptable
代码:
for epic in epics:
if epic['archived'] is False:
print(epic['short_name'], epic['summary'], epic['story_count'])
for story
我有下面的代码,但是not isinstance()并没有像预期的那样工作。
<ipython-input-94-009e9fb4f54a> in extract(self, row)
34 event_payload_json = json.loads(row.event_payload)
35 #print(event_payload_json['payload']['info']['work'])
---> 36 if not is
当我调用getLink()时,我有时会得到这个错误(TypeError:'NoneType‘对象是不可订阅的),有时我不会。有人知道我为什么会得到这个错误吗?getLink()应该是可订阅的... def getLink():
for link in getElements():
if "orgs" in link:
return ['orgs', link]
elif "pac" in link and "summary"
我有以下代码:
cur1.execute("SELECT * FROM consommation WHERE zone=? AND date=?",(zone,date_p))
if cur1.fetchone() is not None:
abcisses+=(cur1.fetchone()[0][11:13]+'h',)
但是当我运行它的时候,我有一个错误:TypeError: 'NoneType' object has no attribute '__getitem__',而cur1.fetchone不是空的。所以我
我有一个这样的列表理解:view['entries'] = [entry for entry in view['entries'] if qs in entry.get('name') or qs in entry.get('description')] 这个列表理解是一个搜索过滤器,它与name字段一起工作,因为它是一个必填字段,不能为空。但是当我搜索description时,我得到了错误TypeError: argument of type 'NoneType' is not iterable 描述字段可以为