我正在調試python代碼(python2.7.12),因爲我的代碼工作正常,但是在向數據庫中傳送推文時,所有變量都爲NULL。異常AttributeError:''NoneType'對象沒有屬性'路徑'「
我得到的錯誤是:
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored
我假定這是錯誤的代碼如下:
def put_tweets_in_database(tweets):
print "putting tweets in database"
errors = 0
count = 0
for tweet in tweets:
try:
commit_tweet_to_database(tweet, count, len(tweets))
count += 1
except Exception as e:
print e
session.rollback()
errors += 1
print 'there were {} errors'.format(errors)
我不認爲功能commit_tweet_to_database()
是錯誤的...
你有什麼想法...?我將不勝感激任何幫助!
謝謝。
我打賭上下文中沒有用戶定義的'_remove',沒有錯誤的行號,並且在循環迭代之間引發異常。所以我懷疑它與循環迭代器有關,可能是Python中的一個錯誤。 –
注意:只有在使用'pdb'(無韻)打開代碼時,纔會出現錯誤。 –