我有个好主意

2024-03-29 09:18:01 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我用的是python-2,我不知道这行有什么问题?我觉得很完美?你知道吗

整个命令如下:

if used_prefix and (cmd=="yp" or cmd=="bal" or cmd=="money" or cmd=="balance") and user.name in whitelist:
        if user.name in yoko:
            room.message(user.name.capitalize()+' your balance is '+yokopoints)
        else:
            room.message(acthelp)

这是错误:

SyntaxError: invalid syntax
stephen@crunchbang:~$ python ~/downloads/inhaley/inhaley.py
  File "/home/stephen/downloads/inhaley/inhaley.py", line 755

if used_prefix and (cmd=="yp" or cmd=="bal" or cmd=="money" or cmd=="balance") and user.name in whitelist:
IndentationError: unindent does not match any outer indentation level

Tags: orandnameincmdprefixifused
1条回答
网友
1楼 · 发布于 2024-03-29 09:18:01

这通常是由混合标签和空间造成的。这会导致问题,因为编辑器的制表符宽度可能与Python的不同。请使用-tt参数运行Python来检查这一点,该参数将显式检查混合缩进的大小和错误,而不是等到解析器混淆为止。这是python3中的默认值。你知道吗

避免此问题的方法是选择要缩进的选项卡或空格,并相应地配置编辑器。正确配置后,按Tab键将始终插入适当的字符(一个制表符或几个空格-4对于Python代码来说是典型的)。如果没有明显的方法来更改设置,您可能需要查看编辑器的文档。你知道吗

相关问题 更多 >