进行类型检查 [英] f---ing typechecking
问题描述
Python 2.5(r25:51908,Sep 19 2006,09:52:17)[MSC v.1310 32 bit(Intel)] on
win32
类型帮助,版权,信用和信用。或许可证或欲获得更多信息。
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>(1,)+ [1]
>>(1,)+[1]
回溯(最近一次调用最后一次):
文件"< stdin>",第1行,<模块>
TypeError:只能将元组(不是list)连接到元组
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate tuple (not "list") to tuple
>> [1] +(1,)
>>[1]+(1,)
Traceback(最近一次调用最后一次) :
文件"< stdin>",第1行,在< module>
TypeError:只能将列表(不是元组)连接到列表
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "tuple") to list
>>>
>>>
它的丑陋和无聊。
Its ugly and boring.
推荐答案
Sergey Dorofeev写道:
Sergey Dorofeev wrote:
Python 2.5(r25:51908,Sep 19 2006,09:52:17)[MSC v.1310
win32
类型帮助,版权,信用等或许可证或欲获得更多信息。
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>(1,)+ [1]
>(1,)+[1]
Traceback(最近一次调用最后一次):
文件"< stdin>",第1行,< module>
TypeError:只能将元组(不是list)连接到元组
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate tuple (not "list") to tuple
> [1] +(1,)
>[1]+(1,)
回溯(最近一次调用最后一次):
文件"< stdin>",第1行,< module>
TypeError:只能连接列表(不是元组)列表
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "tuple") to list
>>
>>
它的丑陋和无聊。
Its ugly and boring.
什么?
对我来说工作正常:
what?
for me it works fine:
>>(1,)+ tuple([1])$ b $ b
>>(1,)+tuple([1])
(1,1)
(1, 1)
>> [1] + list( (1,))
>>[1]+list((1,))
[1,1]
也
[1, 1]
also
>> L = [1]
L.extend((1,) )
L
>>L=[1]
L.extend((1,))
L
[1,1]
[1, 1]
>
Sergey Dorofeev写道:
Sergey Dorofeev wrote:
Python 2.5(r25:51908,Sep 19 2006,09:52:17)[MSC v.1310 32 bit(Intel )] on
win32
输入help,copyright,credit&q UOT;或许可证或更多信息。
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>>(1,)+ [1]
>>>>(1,)+[1]
回溯(最近一次调用最后一次):
文件"< stdin>",第1行,< module>
TypeError:只能将元组(不是list)连接到元组
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate tuple (not "list") to tuple
>>> ;> [1] +(1,)
>>>>[1]+(1,)
回溯(最近一次调用最后一次):
文件" < stdin>",第1行,< module>
TypeError:只能连接列表(不是元组)才能列出
它的丑陋和无聊。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "tuple") to list
Its ugly and boring.
同意。这类似于:
py1 + 1.0
回溯:只能将int添加到int。等等。
但是再一次,缺乏想象力的防守就是如果你能够列出一个列表和一个元组,它就不会是b
。 br />
詹姆斯
Agreed. This would be similar to:
py1 + 1.0
Traceback: can only add int to int. Etc.
But then again, the unimaginative defense would be that it wouldn''t be
python if you could catentate a list and a tuple.
James
它的丑陋和无聊。
这很粗鲁,不必要_and_无聊
Its ugly and boring.
It''s rude, unnecessary _and_ boring
这篇关于进行类型检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!