0
设置,我有以下类型的输入如何转换元组的元组或INT在python
tuple_of_tuple_or_int = ((3,8),4) # it may be like (4,(3,8)) also
我想将其转换为一组像
{3,8,4} # in any order
我已经试过这:
[element for tupl in tuple_of_tuple_or_int for element in tupl]
但它引发以下错误:
TypeError: 'int' object is not iterable
这对我的作品! :D非常感谢! isinstance为+1(tupl,元组) –