在Python中,可以使用type()
函数来判断数据结构的类型。例如:
my_list = [1, 2, 3]
my_dict = {'a': 1, 'b': 2}
my_tuple = (1, 2, 3)
print(type(my_list)) # <class 'list'>
print(type(my_dict)) # <class 'dict'>
print(type(my_tuple)) # <class 'tuple'>
通过type()
函数可以获取数据结构的类型,并根据需要进行相应的操作。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: python闭包函数的作用有哪些