Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
名称错误:名称';处理或存储';未定义,python_Python_Twitter_Tweepy - Fatal编程技术网

名称错误:名称';处理或存储';未定义,python

名称错误:名称';处理或存储';未定义,python,python,twitter,tweepy,Python,Twitter,Tweepy,我试图执行此代码,但收到以下错误消息: NameError:未定义名称“进程或存储” 我在这里尝试了所有相关的解决方案,但没有任何效果。我怎样才能消除错误消息 import tweepy import json import nltk from tweepy import Stream from tweepy import OAuthHandler from tweepy.streaming import StreamListener consumer_key = 'key' consu

我试图执行此代码,但收到以下错误消息:

NameError:未定义名称“进程或存储”

我在这里尝试了所有相关的解决方案,但没有任何效果。我怎样才能消除错误消息

import tweepy
import json
import nltk

from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener



consumer_key = 'key'
consumer_secret = 'secret'
access_token = '-token'
access_secret = 'secret'

auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

api = tweepy.API(auth)

for status in tweepy.Cursor(api.home_timeline).items(10):
    # Process a single status
     process_or_store(status.json)

如R Nar所述,
过程或存储
方法尚未定义。你可以阅读更多关于如何做到这一点的信息

:

函数
process\u或\u store()
是自定义实现的占位符


我想这就是你要找的-

    def process_or_store(tweet):
        print(json.dumps(tweet))
在使用这段代码之前,不要忘记将simplejson作为json导入。这在您提到的网站上可以找到。

只需使用: 打印(json.dumps(friend.\u json))

代替


process\u或\u store(friend.\u json)

你在哪里定义你的
process\u或\u store
方法?那么我如何解决它?…定义它?你认为
process\u或\u store
确切地说是从哪里来的?重复的-这个代码最初来自哪里。