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,元組) –