摘要: # Python3 元组 ''' Python 的元组与列表类似,不同之处在于元组的元素不能修改。 元组使用小括号,列表使用方括号。 元组中只包含一个元素时,需要在元素后面添加逗号,否则括号会被当作运算符使用: ''' tup1 = ('Google', 'Runoob', 1997, 2000); tup2 = (1, 2, 3, 4, 5); tup3 = (50) # 不加逗号,类型为... 阅读全文
posted @ 2019-05-20 17:42 将军上座 阅读(183) 评论(0) 推荐(0) 编辑
摘要: # Python 列表(List) list1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5] list3 = ["a", "b", "c", "d"] ''' Python包含6中内建的序列,即列表、元组、字符串、Unicode字符串、buffer对象和 xrange 对象。 序列通用的操作包括:索引、长度、组... 阅读全文
posted @ 2019-05-20 13:10 将军上座 阅读(177) 评论(0) 推荐(0) 编辑
摘要: import random import math import operator # 数字 # # 1. Python math 模块、cmath 模块 ''' Python math 模块、cmath 模块 Python 中数学运算常用的函数基本都在 math 模块、cmath 模块中。 Python math 模块提供了许多对浮点数的数学运算函数。 Python cmath 模块包含了... 阅读全文
posted @ 2019-05-20 09:15 将军上座 阅读(178) 评论(0) 推荐(0) 编辑
摘要: # 1.Python转义字符 a = "sqwerdf" # 2.Python字符串运算符 ''' + 字符串连接 a + b 输出结果: HelloPython * 重复输出字符串 a*2 输出结果:HelloHello [] 通过索引获取字符串中字符 a[1] 输出结果 e [ : ] 截取字符串中的一部分,遵循左... 阅读全文
posted @ 2019-05-20 09:14 将军上座 阅读(228) 评论(0) 推荐(0) 编辑