随笔分类 -  python面试题

python 列表、元组、字典、集合的区别
摘要:python 列表、元组、字典、字典的区别<摘录> 一、列表 1.任意对象的有序集合 列表是一组任意类型的值,按照一定顺序组合而成的 2.通过偏移读取 组成列表的值叫做元素(Elements)。每一个元素被标识一个索引,第一个索引是0,序列的功能都能实现 3.可变长度,异构以及任意嵌套 列表中的元素 阅读全文

posted @ 2020-04-08 23:09 Sample_天 阅读(1519) 评论(0) 推荐(0)

Python中__init__和self的意义和作用
摘要:init()方法,在创建一个对象时默认被调用,不需要手动调用 #init方法 class Car(): def __init__(self): self.num = 4 self.color = '红色' def taxi(self): print("出发去西湖!") #创建对象 test = Ca 阅读全文

posted @ 2020-04-08 22:52 Sample_天 阅读(1054) 评论(0) 推荐(0)

python 元组、列表、字典、字符串等转换
摘要:1 import json 2 #字典 3 print('dict字典》') 4 dict_test = {'name': 'Zara', 'age': 7, 'class': 'First'} 5 print('初始类型:',type(dict_test)) 6 7 tes=zip(dict_te 阅读全文

posted @ 2020-04-08 17:55 Sample_天 阅读(293) 评论(0) 推荐(0)

导航