简体   繁体   English

为什么此代码会出现错误:“缩进错误:unindent与任何外部缩进都不匹配”

[英]Why this code get error: “Indentation Error: unindent does not match any outer indentation”

My code gating error: 我的代码选通错误:

 File "app.py", line 31
    ed = TwitterBot('Someusername', 'Password@gmail.com')
                                                        ^
IndentationError: unindent does not match any outer indentation level


i have install 
pip- selenium 
geckodriver

from selenium import webdriver from selenium.webdriver.common.keys import Keys import time 从硒导入webdriver从selenium.webdriver.common.keys导入密钥导入时间

class TwitterBot: def init (self, username, password): self.username = username self.password = password self.bot = webdriver.Firefox() TwitterBot类:def init (自身,用户名,密码):self.username =用户名self.password =密码self.bot = webdriver.Firefox()

def login(self):
    bot = self.bot
    bot.get('https://twitter.com/')
    time.sleep(3)
    email = bot.find_element_by_class_name('email-input')
    password = bot.find_element_by_name('sesssion[password]')
    email.clear()
    password.clear()
    email.send_keys(self.username)
    password.send_keys(self.password)
    password.send_keys(Keys.RETURN)
    time.sleep(3)

def like_tweet(self, hashtag):
    bot = self.bot
    bot.get = (
        'https://twitter.com/search?q=' + hashtag + '&src=typd')
    time.sleep(3)

 ed = TwitterBot('Someusername', 'Password@gmail.com') #some error
 ed.login()
 ed.like_tweet('webdevelopment')

Python relies heavily on indentation think of an indented block as being like enclosing code between '{' and '}' in java say. Python严重依赖于缩进,认为缩进的块就像用Java语言将代码括在'{'和'}'之间。 so it is important to return to exactly the same indent when you leave the block as you had before the block. 因此,重要的是,当您离开程序段时,要返回与程序段之前完全相同的缩进。 In this case you don't do that. 在这种情况下,您不会这样做。 It looks as though each of the lines beginning 'ed' starts with a space, remove that space and all will be well. 看起来以“ ed”开头的每一行似乎都以空格开头,删除该空格,一切都会好起来的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “缩进错误:unindent 与任何外部缩进级别不匹配”问题 - “Indentation Error: unindent does not match any outer indentation level” issue Python:“缩进错误:unindent 与任何外部缩进级别都不匹配” - Python: "Indentation Error: unindent does not match any outer indentation level" IndentationError:unindent与python中的任何外部缩进级别错误都不匹配 - IndentationError: unindent does not match any outer indentation level error in python python 3.4 3 unindent与任何外部缩进级别错误都不匹配 - python 3.4 3 unindent does not match any outer indentation level error #错误:unindent与任何外部缩进级别都不匹配 - # Error: unindent does not match any outer indentation level 错误 - 缩进不匹配任何外部缩进级别 - Error - unindent does not match any outer indentation level 错误- IndentationError: unindent 不匹配任何外部缩进级别 - error- IndentationError: unindent does not match any outer indentation level 为什么我有 python 错误 unindent 不匹配任何外部缩进级别错误 - why do i have the python error unindent does not match any outer indentation level error 编译 Python 代码时 unindent does not match any outer indentation level 错误 - unindent does not match any outer indentation level error when compiling the Python code 在python tkinter上获取奇怪的缩进错误-unindent与任何外部缩进级别都不匹配 - Getting weird indentation error on python tkinter - unindent does not match any outer indentation level
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM