gpt4 book ai didi

python - 由于IndentationError : unexpected indent Python而无法写新行

转载 作者:行者123 更新时间:2023-12-03 08:53:00 24 4
gpt4 key购买 nike

我已经阅读了有关此错误的主题,并且空格有问题。
我的问题不是if x == 1 :的问题
我在even_or_odd下添加了x = 2,它抛出

Traceback (most recent call last):
File "server.py", line 16, in <module>
from router import RouteLayer
File "/home/pi/whatsapp-bot-seed/src/router.py", line 13, in <module>
from views.super_kacper import SuperKacper
File "/home/pi/whatsapp-bot-seed/src/views/super_kacper.py", line 25
xd = 2
^
IndentationError: unexpected indent

代码/
from utils.media_sender import UrlPrintSender
from yowsup.layers.protocol_messages.protocolentities.message_text import TextMessageProtocolEntity
import random

class SuperKacper():
def __init__(self, interface_layer):
self.interface_layer = interface_layer
self.url_print_sender = UrlPrintSender(self.interface_layer)
self.routes = [
("/(?P<evenOrOdd>even|odd)$", self.even_or_odd),
]

def even_or_odd(self, message=None, match=None, to=None):
is_odd = len(match.group("evenOrOdd")) % 2
test = 2 #<<<<<<<<<<When I add someting, here test = 2
num = random.randint(1, 10)
if (is_odd and num % 2) or (not is_odd and not num % 2):
return TextMessageProtocolEntity("[%d]\nYou win." % num, to=message.getFrom())
else:
return TextMessageProtocolEntity("[%d]\nYou lose!" % num, to=message.getFrom())

最佳答案

缩进错误,请在此行之前删除空格,然后使用TAB纠正缩进,请尝试:)

关于python - 由于IndentationError : unexpected indent Python而无法写新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35899189/

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