s12-20160109-day02 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* BLOCKS =============================================================================*/ p, blockquote, ul, ol, dl, table, pre { margin…
Python开发(二):列表.字典.元组与文件处理 一:列表二:元组三:字典四:文件处理 一:列表   为什么需要列表 可以通过列表可以对数据实现最方便的存储.修改等操作.字符串是不能修改的,所以无法对数据进行修改.而且可以通过列表进行方便的取值 #  列表的操作 创建列表 >>> name = ["XiaoMing","XiaoHua","XiaoQiang"] >>> name ['XiaoMing', '…
python字符串/列表/字典互相转换 目录 字符串与列表 字符串与字典 列表与字典 字符串与列表 字符串转列表 1.整体转换 str1 = 'hello world' print(str1.split('这里传任何字符串中没有的分割单位都可以,但是不能为空')) # 输出:['helloworld'] 2.分割 str2 = "hello world" list2 = list(str2) print(list2) #输出:['h', 'e', 'l', 'l', 'o', ' ',…
python入门学习:3.操作列表 关键点:列表 3.1 遍历整个列表3.2 创建数值列表3.3 使用列表3.4 元组 3.1 遍历整个列表   循环这种概念很重要,因为它是计算机自动完成重复工作的常见方式之一.下面使用for循环来遍历.  注意for循环的循环体可以包含多行代码,只需要保持缩进即可 1magicians = ['alice','david','carolina']2for magician in magicians:    #依次遍历magicians 将其值存入magicia…
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* BLOCKS =============================================================================*/ p, blockquote, ul, ol, dl, table, pre { margin: 15px 0; } /* HEAD…
一.元组转换 数字 tu = (1) tu1 = (1,) print(tu,type(tu)) print(tu1,type(tu1)) 执行输出: 1 <class 'int'>(1,) <class 'tuple'>  字符串 tu = ('lao') tu1 = ('lao',) print(tu,type(tu)) print(tu1,type(tu1)) 执行输出: lao <class 'str'>('lao',) <class 'tuple'>…
目录 数字类型的内置方法 整型/浮点型 字符串类型的内置方法 列表的内置方法 字典的内置方法 元组的内置方法 集合类型内置方法 布尔类型 数据类型总结 数字类型的内置方法 整型/浮点型 加 + 减 - 乘 * 除 / 取余 % 余数取整 // 字符串类型的内置方法 掌握 熟悉 了解 按索引取值 ,strs[0] lstrip,rstrip find,rfind 切片,str[::-1] lower,upper index,rindex 长度,len[strs] startswith,endswi…
元组(tuple) 元组其实跟列表差不多,也是存一组数,与列表相比,元组一旦创建,便不能再修改,所以又叫只读列表. 语法: names = ("Wuchunwei","Yangmengmeng","Lvs") #元组只有2个方法,一个是count,一个是index >>> tuple1 = (,,,') >>> print (tuple1[]) >>> print (tuple1[-]) &g…
python基础(一): 运算符: 算术运算: 除了基本的+ - * / 以外,还需要知道 :  // 为取整除 返回的市商的整数部分 例如: 9 // 2  ---> 4  , 9.0 //  2.0 --->4.0   %  为取余数  返回的是除法的余数  没有余数则为0  例如: 3 % 3 ---> 0 , 有余数:6 % 3 --->2 逻辑运算符: and , or , not 比较运算符: == 判断两个数是否相等 , != 判断两个数是否不相等 ,  > ,…
什么是元组?(tuple) emmmmmm,这个没必要深究吧,就是一排'元素',一行 格式: a = (1,2,3,4,5,6,7,8,9)用小括号表示的,极为元组. 其有序,且不可更改,可以对比str.list看. 书写的时候注意点,由于()在代码中常见,为了方式发生自己的误读,一般元组在元素最后会补一个逗号.如 print((1,2,3,4,5,6,7,)) 功能情况 .count():查找指定元素在元组中出现了几次 .index():查找指定元素在元组的序号位置 什么是字典?(dict)…