04 2021 档案

摘要:1、创建元祖对象 把序列转化为元组。tuple(a) 注意:元组不可以修改。可切片。 a = [1,2,3,4] b=tuple(a) 结果: (1,2,3,4) 再注意: 单个元素作为元组时,这样创建: b = (1,) 验证:type(b) 结果: <class 'tuple'> 阅读全文
posted @ 2021-04-21 17:00 CiscoLee 阅读(111) 评论(0) 推荐(0) 编辑
摘要:1、列表的排序 a = [1,2,3,4,9,7,6,5,8] a.sort() #默认升序排列,对象不变,元素排序 a.sort(reverse=True) #降序排序 import random #打乱,随机排序 random.shuffle(a) 用法二、 a = sorted(a) #默认升 阅读全文
posted @ 2021-04-21 16:25 CiscoLee 阅读(117) 评论(0) 推荐(0) 编辑
摘要:1 #! /usr/bin/python 2 # -*- coding:UTF-8 -*- 3 4 # pass的使用 5 for letter in 'Python': 6 if letter == 'h': 7 pass #遇到h继续,并且h也算入 8 print("这是pass块") 9 pr 阅读全文
posted @ 2021-04-15 10:31 CiscoLee 阅读(156) 评论(0) 推荐(0) 编辑
摘要:#index()获得指定元素在列表种首次出现的索引 a = [12,34,23,12,23,12,56,34] print(a.index(34)) print(a.index(12,4))#从索引4位置开始查找首次出现的索引 #count()获得指定元素在列表种出现的次数 print(a.coun 阅读全文
posted @ 2021-04-14 19:39 CiscoLee 阅读(142) 评论(0) 推荐(0) 编辑
摘要:#序列,字符串也是一种序列,列表,元组等序列 #序列,都有和字符串类似的操作方法 a = [10,20,30,40] #创建了4个数字对象,a=[....],列表可以放任何元素 print(a) k = 1 for i in range(len(a)): k *= a[i] print(k) #对列 阅读全文
posted @ 2021-04-14 19:26 CiscoLee 阅读(75) 评论(0) 推荐(0) 编辑
摘要:前面python办公自动化有讲部分,这里主要学习操作: chr(编号) #打印对应unicode字符 例如:chr(88) 打印结果: ‘X’ ord(字符) #打印unicode编号 例如:ord("B") 打印结果:’66‘ str(数据) #可以将数值,如整数、浮点数、布尔型数值转换为字符串 阅读全文
posted @ 2021-04-14 10:17 CiscoLee 阅读(51) 评论(0) 推荐(0) 编辑
摘要:import turtleimport math #定义多个点坐标x1,y1 = 100,100x2,y2 = 100,-100x3,y3 = -100,-100x4,y4 = -100,100 #先绘制x轴和y轴,并赋予颜色turtle.color("red")turtle.write("(0,0 阅读全文
posted @ 2021-04-12 13:34 CiscoLee 阅读(910) 评论(0) 推荐(0) 编辑
摘要:0B或0b二进制 #注意开头的是零 0O或0o八进制 0X或0x十六进制 使用: 0b101 # 进制紧跟数字 阅读全文
posted @ 2021-04-12 11:59 CiscoLee 阅读(47) 评论(0) 推荐(0) 编辑
摘要:#绘制奥运五环,一步一步来,然后每一步根据坐标计算【做什么都要先打骨架,如这里先画出五个关键的圆,再去对其进行颜色、何时抬笔、何时落笔的优化,最后才是宽度粗细的把握】import turtleturtle.showturtle()turtle.width(5)turtle.color('DeepSk 阅读全文
posted @ 2021-04-12 11:01 CiscoLee 阅读(989) 评论(0) 推荐(0) 编辑
摘要:1、单行注释: # 注释.... 2、块注释: ''' 这是块注释1 注释2 ''' 或者 """ 这是块注释1 注释2 """ 3、编码声明注释 # coding:utf-8 或 # coding=utf-8 4、行连接符 \ 阅读全文
posted @ 2021-04-12 10:32 CiscoLee 阅读(305) 评论(0) 推荐(0) 编辑
摘要:1、python的命名只能用字母、下划线、数字命名【注意:数字不能作为开头】 2、help(): >>> help() Welcome to Python 3.6's help utility! If this is your first time using Python, you should 阅读全文
posted @ 2021-04-10 13:41 CiscoLee 阅读(494) 评论(0) 推荐(0) 编辑
摘要:第一步导入: >>> import turtle 第二步: >>> turtle.showturtle() 其他步骤:【一个命令一个命令的敲,去体会他的每一个作用】 >>> turtle.write("cisco") >>> turtle.forward(300)>>> turtle.color(" 阅读全文
posted @ 2021-04-10 13:35 CiscoLee 阅读(131) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示