- 博客(26)
- 收藏
- 关注
转载 Python 集合set()
创建# 创建空集合set()# 创建集合,参数必须为 iterableset(it)set(dict) # 只取dict.keys()作为集合的元素特性# 集合特性:无序序列# 集合特性:可变# 集合特性:去重ls = [1, 2, 1]s = set(ls)print(s) # return {1, 2} 内置函数...
2019-09-27 13:36:00
144
转载 Python-100天代码
import turtleturtle.pensize(4)turtle.pencolor('red')turtle.forward(100)turtle.right(90)turtle.forward(100)turtle.right(90)turtle.forward(100)turtle.right(90)turtle.forwa...
2019-05-08 00:14:00
457
转载 删除Windows启动管理器下的加载项
删除Windows启动管理器下的加载项环境:Windows7操作系统工具:cmd命令行工具操作:> msconfig系统配置工具> bededit启动菜单编辑器,命令行工具跳出如下内容:Windows 启动管理器--------------------标识符 ...
2019-02-14 13:57:00
1248
转载 windos7操作系统下easyBCD2.3安装Ubuntu18.04.1-desktop-amd64.iso双系统
准备操作环境:window7操作系统硬件:我的计算机只有一个硬盘,那么标识则为hd0工具:easyBCD2.3镜像:Ubuntu18.04.1-desktop-amd64.iso操作:注意:本人操作是将镜像放在C盘(我的磁盘分区顺序第一位,那么该分区标识为hd0,0)文件位置:镜像存放在C盘(hd0,0)根目录解压出init.l...
2019-02-14 10:58:00
262
转载 Numeric Type -- int, float, complex
Numeric Type -- int, float, complex数字类型分为3类:整数、浮点数和复数;另外布尔是整数的子类整数:无精度限制纯数字的字面量(包括hex、oct、bin的进制数)生成整数浮点数:有精度限制,这取决于你运行的机器,获取信息 “sys.float_...
2019-02-10 20:43:00
274
转载 Comparisons
Comparisons优先级:比较运算符 > 布尔运算符;比较运算符优先级相同比较可以连续:如 x < y <=z,等价于 x<y and y <= z八种比较操作:< strictly less than&...
2019-02-10 18:30:00
230
转载 Truth Value Testing
Truth Value Testing任何对象都可测试真值:通过关键字‘if'或‘while’的条件形式通过Boolean 运算的操作数默认下,对象都是真的,除非对象类型定义以下任一情况:__bool__()方法返回False当对象被调用时,__len__()方法返回...
2019-02-10 14:26:00
111
转载 Boolean Operations -- and, or, not
Boolean Operations -- and, or, not布尔运算操作,优先级按升序排序:x or y 如果x为假,那么y,否则x 短路运算符,只有当参数x为False,才计算参数yx and y 如果x为假,...
2019-02-10 13:18:00
250
转载 enumerate函数
enumerate(iterable, start=0) __next__()方法# 枚举可迭代对象aa = ['Mary', 'had', 'little']for i, e in enumerate(a): print(i, e)# 列出枚举对象seasons = ['Spring', 'Summer', 'Fall', 'Winter...
2019-01-31 16:33:00
110
转载 classmethod函数
# 装饰器函数,表示一个类方法class C: @classmethod def f(cls, args): # cls参数:类对象参数 print(cls) print(args) C.f('类对象调用类方法')c = C() # 创建实例c.f('类实例对象调用类方法...
2019-01-31 14:38:00
151
转载 chr函数
# Unicode编码转为对应字符for i in range(96, 123): print(chr(i))更多: ord()转载于:https://www.cnblogs.com/ShuComputerProgram/p/10340863.html
2019-01-31 10:34:00
393
转载 callable函数
# 判断对象是否可调用,可调用,即对象后加()s = "abc"ls = [1,2,3]def f(): passclass F(): passt =(s, ls, f, F)for obj in t: if callable(obj): print(obj, True) else:...
2019-01-31 10:21:00
167
转载 bytes函数
# source是字符串,则使用str.encode()转换b = bytes('abc',encoding='utf-8',errors='strict')print(b,b[0])# bytes对象不可变try: b[0] = 100except TypeError as err: print('it is immutable.so...
2019-01-31 10:11:00
267
转载 bytearray函数
bytearray: 类,可变字节数组b = bytearray("abc", encoding="utf-8", errors="strict")# bytearray是字节数组序列for c, i in enumerate(b): print(c,i)print(b,b[0]) # 该类形式为 bytearray(b'abc')...
2019-01-31 09:31:00
426
转载 bool函数
bool类 参数基于“标准真值测试程序(Truth testing procedure)”进行转换 bool 是 Numeric Types(int,float,complex)的子类,它不可派生出子类 Boolean Values:布尔值,布尔类的唯一实例 True/False。# 参数缺省,或为flase则返回Falseprint(bool()) # 缺省...
2019-01-30 20:22:00
224
转载 bin函数
# 转为二进制字符串# 整数print(bin(-2)) # 负整数 '-0b10'print(bin(+2)) # 正整数 '0b10'# 非整数必须通过定义__index__()函数实现返回一个整数更多: oct函数 hex函数 特殊方法 __index__ __int__转载于:https:...
2019-01-30 19:52:00
1081
转载 ascii函数
# 返回可打印的字符串,等价repr()函数# ascii编码字符print(ascii('learn python!'))print(ascii(9876543210))# 非ascii编码字符,转换为\x,\u或\U的Unicode编码print(ascii("中")) # 中文print(ascii("β")) # 德文...
2019-01-30 19:24:00
341
转载 any函数
# 可迭代对象为空则假print(any(""))print(any([]))# 任一元素为真则真print(any([1,2,None]))print(any([1,2,'']))转载于:https://www.cnblogs.com/ShuComputerProgram/p/10339379.html...
2019-01-30 18:37:00
188
转载 all函数
判断可迭代对象的元素为真(空迭代对象为真)# 可迭代对象为空则真print(all(""))print(all([]))# 全部元素为真则真,否则为Falseprint(all([1,2,None])) # None为Falseprint(all([1,2,'',3])) # ''空字符串为False# 等价函数def all(iter...
2019-01-30 18:29:00
147
转载 abs函数
# 返回绝对值n = [-1, 1.1, 3+4j]for i in n: print(abs(i))# 如果参数为complex,则返回其模运算结果转载于:https://www.cnblogs.com/ShuComputerProgram/p/10339302.html...
2019-01-30 18:10:00
148
转载 virtualenv模块使用
开发多个应用: 如A需要jinja2.7开发;如B需要jinja2.6开发。或者C需要Python2.7开发,D需要Python3.5开发那么解决上述问题就需要使用virtualenv这个模块: 它的作用是:创建“隔离”环境,使项目拥有独立的Python运行环境下载:(存在:安装Python版本2和3的) py -2 -m pip install virt...
2019-01-30 15:45:00
140
转载 string模块
# string Moudle"""Data: ascii_letters 大小写字母 ascii_lowercase 小写字母 ascii_uppercase 大写字母 digits 数字0-9 hexdigits ...
2019-01-30 13:06:00
87
转载 字符串替换
# 字符串替换s = " work hard"print(s.replace('r', '0')) # new replace oldprint(s.replace('wo', '01'))print(s.replace('d', '0')) # old not in s, return sprint(s.replace('r', '0', 1))...
2019-01-30 11:19:00
110
转载 字符串大小写
# 字符串大小写s = 'learn python3's = s.upper() # 转换字母,大写print(s, s.isupper()) # 判断字母,是否为大写s = s.lower() # 转换字母,小写print(s, s.islower()) # 判断字母,是否为小写转载于:https://www.cnblogs.c...
2019-01-30 10:43:00
145
转载 Python3循环中的break、continue语句
break语句用来终止循环语句如果您使用嵌套循环,break语句将停止执行最深层的循环,并开始执行下一行代码。def f(): for i in range(10): for j in range(10): # 中断该层循环 print(i,j) if j == 4: ...
2018-11-30 10:26:00
161
转载 实例:雪景艺术绘图
雪景艺术绘图 turtle艺术绘制图形艺术,指利用turtle库画笔创造性绘制绚丽多彩艺术图形的过程 turtle图形艺术效果中隐含着很多随机元素,如随机颜色、尺寸、位置和数量等。在图形艺术绘制中需要引入随机函数库random。常用randint()函数,生成指定范围内的随机数 “雪景”图形艺术背景为黑色,分为上下两个区域,上方是漫天彩色雪花,下方是由远及近的灰色横线...
2018-11-16 22:34:00
337
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人