<tfoot id='NIbky'></tfoot>
      • <bdo id='NIbky'></bdo><ul id='NIbky'></ul>

        <small id='NIbky'></small><noframes id='NIbky'>

        <legend id='NIbky'><style id='NIbky'><dir id='NIbky'><q id='NIbky'></q></dir></style></legend>

        <i id='NIbky'><tr id='NIbky'><dt id='NIbky'><q id='NIbky'><span id='NIbky'><b id='NIbky'><form id='NIbky'><ins id='NIbky'></ins><ul id='NIbky'></ul><sub id='NIbky'></sub></form><legend id='NIbky'></legend><bdo id='NIbky'><pre id='NIbky'><center id='NIbky'></center></pre></bdo></b><th id='NIbky'></th></span></q></dt></tr></i><div id='NIbky'><tfoot id='NIbky'></tfoot><dl id='NIbky'><fieldset id='NIbky'></fieldset></dl></div>

        TypeError: __init__() 至少需要 4 个非关键字参数(给定 3 个)

        TypeError: __init__() takes at least 4 non-keyword arguments (3 given)(TypeError: __init__() 至少需要 4 个非关键字参数(给定 3 个))
        <i id='9QVj9'><tr id='9QVj9'><dt id='9QVj9'><q id='9QVj9'><span id='9QVj9'><b id='9QVj9'><form id='9QVj9'><ins id='9QVj9'></ins><ul id='9QVj9'></ul><sub id='9QVj9'></sub></form><legend id='9QVj9'></legend><bdo id='9QVj9'><pre id='9QVj9'><center id='9QVj9'></center></pre></bdo></b><th id='9QVj9'></th></span></q></dt></tr></i><div id='9QVj9'><tfoot id='9QVj9'></tfoot><dl id='9QVj9'><fieldset id='9QVj9'></fieldset></dl></div>

                <bdo id='9QVj9'></bdo><ul id='9QVj9'></ul>

                <small id='9QVj9'></small><noframes id='9QVj9'>

                  <legend id='9QVj9'><style id='9QVj9'><dir id='9QVj9'><q id='9QVj9'></q></dir></style></legend>

                    <tbody id='9QVj9'></tbody>
                  <tfoot id='9QVj9'></tfoot>

                1. 本文介绍了TypeError: __init__() 至少需要 4 个非关键字参数(给定 3 个)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  请指教:)

                  当我使用这个脚本时:

                  class CustomStreamListener(tweepy.StreamListener):
                  
                      def on_status(self, status):
                  
                          # We'll simply print some values in a tab-delimited format
                          # suitable for capturing to a flat file but you could opt 
                          # store them elsewhere, retweet select statuses, etc.
                  
                  
                  
                          try:
                              print "%s	%s	%s	%s" % (status.text, 
                                                        status.author.screen_name, 
                                                        status.created_at, 
                                                        status.source,)
                          except Exception, e:
                              print >> sys.stderr, 'Encountered Exception:', e
                              pass
                  
                      def on_error(self, status_code):
                          print >> sys.stderr, 'Encountered error with status code:', status_code
                          return True # Don't kill the stream
                  
                      def on_timeout(self):
                          print >> sys.stderr, 'Timeout...'
                          return True # Don't kill the stream
                  
                  # Create a streaming API and set a timeout value of 60 seconds.
                  
                  streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=60)
                  
                  # Optionally filter the statuses you want to track by providing a list
                  # of users to "follow".
                  
                  print >> sys.stderr, 'Filtering the public timeline for "%s"' % (' '.join(sys.argv[1:]),)
                  
                  streaming_api.filter(follow=None, track=Q)
                  

                  出现这样的错误:

                  Traceback (most recent call last):
                    File "C:/Python26/test.py", line 65, in <module>
                      streaming_api = tweepy.streaming.Stream(auth, CustomStreamListener(), timeout=60)
                  TypeError: __init__() takes at least 4 non-keyword arguments (3 given)
                  

                  那我该怎么办?

                  推荐答案

                  您的示例似乎来自 这里.您正在使用 Tweepy,这是一个用于访问 Twitter API 的 Python 库.

                  Your example appears to be from here. And you are using Tweepy, a Python library for accessing the Twitter API.

                  来自 Github,这里是一个Stream() 对象(假设你有最新版本的 Tweepy,请仔细检查!),

                  From Github, here is the definition of a Stream() object (assuming you have the latest version of Tweepy, please double check!),

                  def __init__(self, auth, listener, **options):
                          self.auth = auth
                          self.listener = listener
                          self.running = False
                          self.timeout = options.get("timeout", 300.0)
                          self.retry_count = options.get("retry_count")
                          self.retry_time = options.get("retry_time", 10.0)
                          self.snooze_time = options.get("snooze_time",  5.0)
                          self.buffer_size = options.get("buffer_size",  1500)
                          if options.get("secure"):
                              self.scheme = "https"
                          else:
                              self.scheme = "http"
                  
                          self.api = API()
                          self.headers = options.get("headers") or {}
                          self.parameters = None
                          self.body = None
                  

                  因为您似乎传递了适当数量的参数,所以看起来 CustomStreamListener() 没有被初始化,因此没有被传递给 Stream() 类作为参数.查看是否可以在将 CustomStreamListener() 作为参数传递给 Stream() 之前对其进行初始化.

                  Because you seemed to have passed in the appropriate number of arguments, it looks like CustomStreamListener() isn't being initialized, and therefore isn't being passed to the Stream() class as an argument. See if you can initialize a CustomStreamListener() prior to being passed as an argument to Stream().

                  这篇关于TypeError: __init__() 至少需要 4 个非关键字参数(给定 3 个)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                    <tfoot id='FlvjW'></tfoot>
                      <tbody id='FlvjW'></tbody>
                    1. <small id='FlvjW'></small><noframes id='FlvjW'>

                        <bdo id='FlvjW'></bdo><ul id='FlvjW'></ul>
                        <legend id='FlvjW'><style id='FlvjW'><dir id='FlvjW'><q id='FlvjW'></q></dir></style></legend>

                        • <i id='FlvjW'><tr id='FlvjW'><dt id='FlvjW'><q id='FlvjW'><span id='FlvjW'><b id='FlvjW'><form id='FlvjW'><ins id='FlvjW'></ins><ul id='FlvjW'></ul><sub id='FlvjW'></sub></form><legend id='FlvjW'></legend><bdo id='FlvjW'><pre id='FlvjW'><center id='FlvjW'></center></pre></bdo></b><th id='FlvjW'></th></span></q></dt></tr></i><div id='FlvjW'><tfoot id='FlvjW'></tfoot><dl id='FlvjW'><fieldset id='FlvjW'></fieldset></dl></div>