异常 AttributeError:“'NoneType' 对象没有属性 'path'”

wan*_*ppy 5 attributeerror python-2.7 try-except

我正在调试 python 代码(python2.7.12),因为我的代码可以工作,但是当我将推文流式传输到数据库时,所有变量都为 NULL。

我得到的错误是:

Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored
Run Code Online (Sandbox Code Playgroud)

我假设这个错误来自下面的代码:

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)
Run Code Online (Sandbox Code Playgroud)

我不认为这个功能commit_tweet_to_database()有问题...

你有什么主意吗...?我将不胜感激任何帮助!

谢谢。

Ank*_*wal 1

Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored
Run Code Online (Sandbox Code Playgroud)

这表明在函数中尝试访问对象上的_remove属性。对象没有属性。因此,您可能需要查看功能并从那里开始调试。pathNoneTypeNoneType_remove