gpt4 book ai didi

Python IndentationError unindent 不匹配任何外部缩进级别

转载 作者:太空狗 更新时间:2023-10-29 20:32:46 25 4
gpt4 key购买 nike

<分区>

我是 python 的初学者,

我有这个错误:

Error : 
def on_data(self,data):
^
IdentationError : unindent does not match any outer indentation level

我在 windows 8.1 中使用 notepad++ 编写代码。我不明白为什么会出现此错误,我已经注意制表符和空格。

我想将数据保存在self.file中

这是我的代码:

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



class StdOutListener(StreamListener):

def __init__(self,file):
self.file = file

def on_data(self, data):

print data
self.file.write(data)
return True

def on_error(self, status):
print status


def main() :
file = open('work.txt','w')
listn = StdOutListener(file)
consumer_key=""
consumer_secret=""

access_token=""
access_token_secret=""

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
#api = tweepy.API(auth)

#filename=open('helloworld.txt','r')
#f=filename.readlines()
#filename.close()

#for line in f:
# api.update_status(line)

stream = Stream(auth, listn)
stream.filter(track=['lol'])
file.close()

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com