一、元组转换成字典
tuple_var = ((1, 2), (3, 4)) print(dict(tuple_var), type(tuple_var))
{1: 2, 3: 4} <class 'tuple'>
二、列表转换成字典
list_var = [(1, 2), (3, 4)] print(dict(list_var), type(list_var))
{1: 2, 3: 4} <class 'list'>
tuple_var = ((1, 2), (3, 4)) print(dict(tuple_var), type(tuple_var))
{1: 2, 3: 4} <class 'tuple'>
list_var = [(1, 2), (3, 4)] print(dict(list_var), type(list_var))
{1: 2, 3: 4} <class 'list'>