小编Geo*_*rey的帖子

01208在python中有特殊含义还是只是python2.6.2的bug?

在python运行时环境中,尝试以下方法:

>> *type(01207)*
Run Code Online (Sandbox Code Playgroud)

你会得到:

<type 'int'>
Run Code Online (Sandbox Code Playgroud)

然后尝试:

>> *type(01208)*
Run Code Online (Sandbox Code Playgroud)

你会得到:

File "<stdin>", line 1
type(01208)
         ^
Run Code Online (Sandbox Code Playgroud)

python

2
推荐指数
1
解决办法
92
查看次数

特殊方法__cmp__不起作用

这项特殊工作__cmp__不起作用.说下面的代码:

class Test():
      def __cmp__(self, other):
           return False

t1 = Test()
t2 = t1

print t2 == t1
Run Code Online (Sandbox Code Playgroud)

我应该得到假,因为cmp总是返回False.但实际上,python正在为我打印True.

有什么建议吗?

python

-1
推荐指数
1
解决办法
107
查看次数

标签 统计

python ×2