在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) 这项特殊工作__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 ×2