摘要: #元祖,是只读列表,可循环查询,可切片 #儿子不能改,孙子可以改(元祖里的列表中的元素可以改) tu = (1,2,3,'alex',[2,3,4,'taibai'],'egon') print(tu[3]) print(tu[0:4]) for i in tu: print(i) tu[4][3] = tu[4][3].upper() print(tu) s = 'alex' ... 阅读全文
posted @ 2019-07-09 20:43 西庇阿 阅读(88) 评论(0) 推荐(0)
摘要: #字典的学习 #字典是键值对的无序集合。向字典添加一个键的同时,必须为该键增添一个值。(之后可以随时修改该值。)python的字典为通过键获取值进行了优化,而不是反过来 #python中的字典与perl5中的hash【散列】类似。python中,变量可以随意命名,而python内部跟踪其数据类型 #1、创建字典 a_dict = {'server':'db.diveintopython3.or... 阅读全文
posted @ 2019-04-26 22:46 西庇阿 阅读(184) 评论(0) 推荐(0)
摘要: #集合的学习 #集合set是装有独特值的无序"袋子",一个简单的集合可以包含任何数据类型的值。如果有两个集合,则可以执行像联合、交集以及集合求差等标准集合运算 #1、创建集合 a_set = {1} print(a_set) type(a_set) a_set = {1,2} print(a_set) #2、以列表为基础创建集合 a_list = ['a','b','sicpio','ice'... 阅读全文
posted @ 2019-04-26 22:05 西庇阿 阅读(166) 评论(0) 推荐(0)
摘要: 1 #元组 是不可变的列表。一但创建后,任何方法都不可以修改元素 2 a_tuple = ("a","b","mpilgrim","z","example") 3 print(a_tuple) 4 print(a_tuple[1]) 5 print(a_tuple[-1]) 6 print(a_tuple[1:3]) 7 8 #元组 同时赋多个值 9 v = ('a',2,T... 阅读全文
posted @ 2019-04-23 21:32 西庇阿 阅读(97) 评论(0) 推荐(0)
摘要: #列表的增、删、改、查 #增加 append li=['Scipio',[1,2,3],'wusir','egon','女神','taibai'] li.append('日天') print(li) ''' #Fraction 函数 ''' ''' x = 0 import fractions x = fractions.Fraction(2,3) print(x) x1=x x1=fract... 阅读全文
posted @ 2019-04-23 20:50 西庇阿 阅读(120) 评论(0) 推荐(0)