- 博客(15)
- 收藏
- 关注
原创 变量,变量命名规则
a = [1,2,3]把列表[1,2,3]赋值给变量a变量命名:字母、数字、下划线这三者的任意组合,变量区分大小写首字母不可是数字,变量不能是系统的保留关键字 >>> 1a = 2SyntaxError: invalid syntax>>> _a = 2>>> a_1 = 3动态语言值类型,引用类型值类型(不可变 int str tupl...
2018-05-20 11:30:17
706
原创 set(集合) ,dict(字典)
set特点: >>> {3,3,4,4,5,6,7,7}{3, 4, 5, 6, 7}空集合:set()操作:不支持:通过序号访问数据、切片操作、+、*支持:in ,len(), -(差值), |(并集), &(交集)>>> 2 in {2,3,4}True>>> len({3,4,5,6})4>>> max...
2018-05-19 12:32:23
549
原创 序列总结(str, list, tuple)
str,list,tuple 都是序列,序列即是有序的序列的共同操作:1、通过序号访问数据>>> 'hello world'[0]'h'>>> [1,2,3,4,'abc'][2]3>>> (2,3,'python',4)[2]'python'2、切片操作>>> [1,2,3,4,'abc','python'][-3...
2018-05-14 18:28:37
547
原创 元组的奇怪现象
>>> (1,'abc',True,[1,2,3])(1, 'abc', True, [1, 2, 3])元组内数据的访问与list,str的一样:>>> (1,'abc',True,[1,2,3],'python','java')[0]1>>> (1,'abc',True,[1,2,3],'python','java')[2]True...
2018-05-14 17:59:05
170
原创 列表(list)的操作
列表的特点:1、列表中可以存在各种类型的数据>>> [1,2,'abc',[2,4,5],True,False][1, 2, 'abc', [2, 4, 5], True, False]2、列表截取时,如果使用序列的方式提取得到的是字符串,如果使用’:‘的方式提取得到还是个列表 >>> ['abc','python','c++','java'][0]'abc...
2018-05-14 17:26:06
290
原创 字符串运算
1、加,乘>>> 'hello'+'world''helloworld'>>> 'hello'*3'hellohellohello'2、字符串运算(一)>>> 'hello world'[0]'h'>>> 'hello world'[4]'o'>>> 'hello world'[-1]
2018-05-14 17:02:23
1857
原创 转义字符 ’\‘
一、转义字符是一类特殊的字符:1、展示无法’看见‘的字符2、与语言本身语法有冲突的字符\n 换行\t 横向制表符\' 单引号>>> print('hello \n world')hello world>>> print('hello \\n world')hello \n world\n 换行\r 回车二、原始字符:>>&g...
2018-05-14 16:22:33
12953
1
原创 单引号,双引号,三引号
1、单引号,双引号 用来表示字符串str时必须是成对出现的>>> 'hello word''hello word'>>> "hello word"'hello word'>>> "Let's go""Let's go">>> 'Let's go'SyntaxError:
2018-05-14 15:29:49
1162
原创 python-布尔类型bool
布尔类型是Number这种数据类型中的一种True False 非0的数据转化为布尔类型都是True0转化为布尔类型是False非空的字符串转化为布尔类型都是True空的字符串转化为布尔类型是False以上同样适用于列表和元组>>> TrueTrue>>> FalseFalse>>> bool(1)True>>>...
2018-05-14 14:47:51
453
原创 2进制,8进制,10进制,16进制在python中的表示方法和互相转换函数
2进制:满2进1 , 0b108进制:满8进1 , 0o1010进制:满10进1 , 1016进制:满16进1 , 0x10时间满60进1bin() 转2进制方法int() 转10进制方法oct() 转8进制方法hex() 转16进制方法>>> bin(20)'0b10100'>>> bin(0o45)'0b100101'>&...
2018-05-14 14:31:28
29764
原创 python ‘//’ 取整,‘%’ 取余
>>> 2/2 除法1.0>>> 2//2 取整1>>> 1/2 除法0.5>>> 1//2 取整0>>> 3//2 取整1>>> 3%2 取余1>>> 4%2 取余0
2018-05-14 12:05:42
86897
2
原创 python -- sorted() 函数与 .sort() 的区别
lists = [8,2,4,1,5,7,3]# 对lists进行排序,但不改变listsprint(sorted(lists))# 对lists进行排序,且改变了listslists.sort()print(lists)
2018-05-03 21:52:06
198
原创 python-算法
1、冒泡算法def bubble_sort(lists): count = len(lists) for i in (0,count): for j in (i+1,count): if lists[i] > lists[j]: lists[i] , lists[j] = lists[j] , ...
2018-05-03 21:01:42
182
原创 sql--查询
查询id重复3次以上的数据:select * from users where id in ( select id from users group by id having count(*)>=3 )查询前10条数据并按age排序:select * from users where 1=1 order by age limit 10...
2018-05-03 20:05:41
179
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人