|
楼主 |
发表于 2017-5-12 22:24:17
|
显示全部楼层
好的,我针对这个题,我又改了一下,但还是报错了。不明白为什么报这错- def BinSelf(x):
- lista = []
- string = ''
- while x:
- i = x % 2
- x = x // 2
- lista.append[i]
- print(lista.reverse())
- for a in lista:
- string +=str(lista(a))
- print(string)
复制代码
报错如下: 为什么会说 lista.append
TypeError: 'builtin_function_or_method' object is not subscriptable
- >>> BinSelf(2)
- Traceback (most recent call last):
- File "<pyshell#30>", line 1, in <module>
- BinSelf(2)
- File "<pyshell#29>", line 7, in BinSelf
- lista.append[i]
- TypeError: 'builtin_function_or_method' object is not subscriptable
- >>>
复制代码 |
|