鱼C论坛

 找回密码
 立即注册
查看: 1099|回复: 3

[已解决]为什么我又找不到自己的错误在哪。。。。。

[复制链接]
发表于 2020-8-19 15:12:38 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
file:///D:/X%7BX03%5DVXABYF0IK6(6MVO34.png



class CountList:
        def __init__(self,*args):
                self.values = [x for x in arges]
                print(self.values)
                self.count = {}.fromkeys(range(len(self.values)),0)

        def __len__(self):
            return len(self.values)

        def __getitem__(self,key):
            self.count[key] += 1
            return self.values[key]
        
SyntaxError: inconsistent use of tabs and spaces in indentation
最佳答案
2020-8-19 15:13:56
缩进 Tab 和空格混用了,而且你的代码中还有一个拼写错误。帮你改好了:

  1. class CountList:
  2.     def __init__(self, *args):
  3.         self.values = [x for x in args]
  4.         print(self.values)
  5.         self.count = {}.fromkeys(range(len(self.values)), 0)

  6.     def __len__(self):
  7.         return len(self.values)

  8.     def __getitem__(self, key):
  9.         self.count[key] += 1
  10.         return self.values[key]
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-8-19 15:13:53 | 显示全部楼层
本帖最后由 永恒的蓝色梦想 于 2020-8-19 15:16 编辑
  1. class CountList:
  2.     def __init__(self,*args):
  3.         self.values = [x for x in args]
  4.         print(self.values)
  5.         self.count = dict.fromkeys(range(len(self.values)),0)

  6.     def __len__(self):
  7.         return len(self.values)

  8.     def __getitem__(self,key):
  9.         self.count[key] += 1
  10.         return self.values[key]
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-19 15:13:56 | 显示全部楼层    本楼为最佳答案   
缩进 Tab 和空格混用了,而且你的代码中还有一个拼写错误。帮你改好了:

  1. class CountList:
  2.     def __init__(self, *args):
  3.         self.values = [x for x in args]
  4.         print(self.values)
  5.         self.count = {}.fromkeys(range(len(self.values)), 0)

  6.     def __len__(self):
  7.         return len(self.values)

  8.     def __getitem__(self, key):
  9.         self.count[key] += 1
  10.         return self.values[key]
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-8-20 09:41:51 | 显示全部楼层
zltzlt 发表于 2020-8-19 15:13
缩进 Tab 和空格混用了,而且你的代码中还有一个拼写错误。帮你改好了:

谢谢大佬
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-2 01:18

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表