摘要: 数学函数 函数 返回值 ( 描述 ) abs(x) 返回数字的绝对值,如abs(-10) 返回 10 ceil(x) 返回数字的上入整数,如math.ceil(4.1) 返回 5 cmp(x, y) 如果 x y 返回 1。 Python 3 已废弃 。使用 使用 (x>y)-(x<y) 替换。 exp(x) 返回e的x次幂(ex),如math.exp(1) 返回2.7... 阅读全文
posted @ 2018-08-27 11:30 principles 阅读(108) 评论(0) 推荐(0)
摘要: Python列表函数&方法 len(list) 列表元素个数 max(list) 返回列表元素最大值 min(list) 返回列表元素最小值 list(seq) 将元组转换为列表 list.append(obj) 在列表末尾添加新的对象 list.count(obj) 统计某个元素在列表中出现的次数 list.extend(seq) 在列表末尾一次性追加另一个序列中的多个值(用新列... 阅读全文
posted @ 2018-08-27 11:29 principles 阅读(108) 评论(0) 推荐(0)
摘要: 转义字符 在需要在字符中使用特殊字符时,python用反斜杠(\)转义字符。如下表: \(在行尾时) 续行符 \\ 反斜杠符号 \' 单引号 \" 双引号 \a 响铃 \b 退格(Backspace) \e 转义 \000 空 \n 换行 \v 纵向制表符 \t 横向制表符 \r 回车 \f 换页 \oyy 八进... 阅读全文
posted @ 2018-08-27 11:29 principles 阅读(112) 评论(0) 推荐(0)
摘要: 元组内置函数 len(tuple) 计算元组元素个数。 >>> tuple1 = ('Google', 'Runoob', 'Taobao') >>> len(tuple1) 3 max(tuple) 返回元组中元素最大值。 >>> tuple2 = ('5', '4', '8') >>> max(tuple2) '8' min(tuple) 返回元组中元素最小值。 >>> tuple2 = ( 阅读全文
posted @ 2018-08-27 11:28 principles 阅读(110) 评论(0) 推荐(0)
摘要: int 整数,只有一种整型类型,长整型 bool 布尔,如:true float 浮点、小数 complex 复数,如:1+2j、1.1+2.2j 字符串(string) 转移符:“\” 反斜杠可以用来转义,加入r可以让反斜杠不发生转义,如:r"this is line with"\n 则\n会显示,不会换行 python中有两种索引方式,从做到右从0开始,从右到左从-1开始 python字符... 阅读全文
posted @ 2018-08-27 11:27 principles 阅读(126) 评论(0) 推荐(0)
摘要: 多个变量赋值:a , b , c = 1 标准数据类型 number(数字)、string(字符串)、list(列表)、tuple(元组)、set(集合)、dictionary(字典) 可变类型: list(列表)、set(集合)、dictionary(字典) 不可变类型: number(数字)、string(字符串)、tuple(元组) 内置type() 函数可以用来查询变量所... 阅读全文
posted @ 2018-08-27 11:26 principles 阅读(134) 评论(0) 推荐(0)