摘要: pass python中空代码块是非法的,解决的方法就是在语句块中加上一个pass语句 eval >>> eval("print('hellowrold')")hellowrold 阅读全文
posted @ 2019-06-24 18:11 嵌入式实操 阅读(307) 评论(0) 推荐(0) 编辑
摘要: result: 阅读全文
posted @ 2019-06-24 18:05 嵌入式实操 阅读(249) 评论(0) 推荐(0) 编辑
摘要: result: example2: result : 阅读全文
posted @ 2019-06-24 17:50 嵌入式实操 阅读(188) 评论(0) 推荐(0) 编辑
摘要: while 语句: for 语句: 阅读全文
posted @ 2019-06-24 17:33 嵌入式实操 阅读(238) 评论(0) 推荐(0) 编辑
摘要: >>> age = 10 >>> assert 0 ", line 1, in AssertionError >>> assert 0 < age < 11 阅读全文
posted @ 2019-06-24 17:29 嵌入式实操 阅读(118) 评论(0) 推荐(0) 编辑
摘要: x == y x < y x <= y x >= y x != y x is y x is not y x in y x not in y 阅读全文
posted @ 2019-06-24 17:28 嵌入式实操 阅读(191) 评论(0) 推荐(0) 编辑
摘要: int(x [,base ]) 将x转换为一个整数 long(x [,base ]) 将x转换为一个长整数 float(x ) 将x转换到一个浮点数 complex(real [,imag ]) 创建一个复数 str(x ) 将对象 x 转换为字符串 repr(x ) 将对象 x 转换为表达式字符串 阅读全文
posted @ 2019-06-24 17:22 嵌入式实操 阅读(4208) 评论(0) 推荐(0) 编辑
摘要: name = input('what is your name?')if name.endswith('zd'): print("hello panzidong") name = input('what is your name?')if name.endswith('zd'): print("he 阅读全文
posted @ 2019-06-24 17:18 嵌入式实操 阅读(443) 评论(0) 推荐(0) 编辑
摘要: 序列解包: >>> x,y,z = 1, 2, 3>>> print(x, y, z)1 2 3 >>> a,b, *reset = [1,2,3,4]>>> print(a,b,reset)1 2 [3, 4] 链式赋值: x = y = function 增量赋值: >>> x = 2>>> x 阅读全文
posted @ 2019-06-24 17:09 嵌入式实操 阅读(168) 评论(0) 推荐(0) 编辑
摘要: >>> print("aaaa","bbbb")aaaa bbbb>>> print(1, 2, 3)1 2 3 为模块提供别名: >>> import math as foobar>>> foobar.sqrt(4)2.0 为函数提供别名: >>> from math import sqrt as 阅读全文
posted @ 2019-06-24 17:03 嵌入式实操 阅读(749) 评论(0) 推荐(0) 编辑
摘要: 字典的创建: >>> phonebook = { 'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'} dict函数: >>> items = [('name','pan'),('age', 32)]>>> d = dict(items)>>> d{'n 阅读全文
posted @ 2019-06-24 16:55 嵌入式实操 阅读(163) 评论(0) 推荐(0) 编辑
摘要: key point: 字符串都是不可改变的 打印: >>> values('world', 'hot')>>> format'hello, %s. %s enough for ya'>>> print(format % values)hello, world. hot enough for ya > 阅读全文
posted @ 2019-06-24 16:02 嵌入式实操 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 元组与列表一样,也是一样序列,唯一的不同是元组不能修改 如果用逗号分隔了一些值,那么你就自动创建了元组 >>> 3 * (40 + 2)126>>> 3 * (40 + 2,)(42, 42, 42) tuple 以一个序列作为参数并把它转换为元组 >>> tuple([1,2,3])(1, 2, 阅读全文
posted @ 2019-06-24 15:23 嵌入式实操 阅读(127) 评论(0) 推荐(0) 编辑
摘要: list('hello')['h', 'e', 'l', 'l', 'o'] 操作方法: 1.改变例表:元素赋值 x = [1, 1, 1]x [1] = 2x[1, 2, 1] 2. 删除元素 names = ['tu','dong', 'nana', 'test']names['tu', 'do 阅读全文
posted @ 2019-06-24 15:08 嵌入式实操 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 通用序列操作:索引:greeting=hellogreeting[0]分片:number[1,2,3,4,5,6]number[3:6]number[3:6:1]序列相加:[1,2,3] + [4,5,6][1,2,3,4,5,6]乘法'p' * 5'ppppp'成员次格:permissions = 阅读全文
posted @ 2019-06-24 14:52 嵌入式实操 阅读(212) 评论(0) 推荐(0) 编辑