随笔 - 22, 文章 - 0, 评论 - 0, 阅读 - 3725
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  python / python基本知识

摘要:问题: 如何查找在两个字典中相同的键、值元素? dict1 = {'a': 1, 'b': 2, 'c': 3} dict2 = {'a': 10, 'y': 11,'b': 2} dict1.keys() & dict2.keys() # 交集 dict1.keys() - dict2.keys( 阅读全文

posted @ 2024-02-20 22:53 生活旅行家 阅读(41) 评论(0) 推荐(0) 编辑

摘要:队列,堆栈是程序开发中常用的两种数据存储模型。python中队列怎么运用呢?以下内容介绍了队列的使用和队列的函数。 from collections import deque q = deque() q.append('a') q.append('b') q.appendleft('c') prin 阅读全文

posted @ 2024-01-26 16:02 生活旅行家 阅读(22) 评论(0) 推荐(0) 编辑

摘要:一、如果知道序列中元素的个数,可以直接进行变量赋值。 coords = (102, 40) lon, lat = coords print(lon) print(lat) text = "news" a, b, c, d = text print(a) print(b) print(c) print 阅读全文

posted @ 2024-01-26 11:55 生活旅行家 阅读(12) 评论(0) 推荐(0) 编辑

摘要:import smtplib from email.mime.text import MIMEText #邮件正文 from email.header import Header #邮件头 #登录邮件服务器 smtp_obj = smtplib.SMTP_SSL("smtp.email.qq.com 阅读全文

posted @ 2023-03-15 23:34 生活旅行家 阅读(13) 评论(0) 推荐(0) 编辑

摘要:安装 pip install openpyxl 一、打开文件 创建文件 from openpyxl import Workbook # 实例化 wb = Workbook() # 获取当前active sheet sheet = wb.active # 打印sheet表名 print(sheet.t 阅读全文

posted @ 2023-03-12 22:11 生活旅行家 阅读(38) 评论(0) 推荐(0) 编辑

摘要:常用函数: random.randrange(1,10) 返回1-9之间的一个随机数 random.randint(1,10) 返回1-10之间的一个随机数,包括10 random.randrange(0,100,2) 返回0-100之间的偶数 random.random() 返回一个随机浮点数 r 阅读全文

posted @ 2023-03-12 21:43 生活旅行家 阅读(19) 评论(0) 推荐(0) 编辑

摘要:相比time模块,datetime模块的接口更直观,更容易调用 datetime模块定义了下面几个类: datetime.date 表示日期的类,常用的属性有year,month,day; datetime.time 表示时间的类,常用的属性有hour,minute,second,microseco 阅读全文

posted @ 2023-03-10 12:07 生活旅行家 阅读(36) 评论(0) 推荐(0) 编辑

摘要:python程序编写中的时间处理涉及三种: 1、时间的显示; 2、时间的转换; 3、时间的运算。 时间处理模块:time模块 时间的三种表示方式: ①时间戳,从1970年1月1日开始,每过1s增加1,如下: 263625632.623462 ②人们常用的字符串时间表达方式: 2023-03-03 1 阅读全文

posted @ 2023-03-09 23:30 生活旅行家 阅读(84) 评论(0) 推荐(0) 编辑

摘要:模块的概念:为了减少常用代码重复输入,同时方便多人协作,python中定义了模块一词。 模块是一些函数的集合。在python中可以使用import导入某一模块的单个或者所有功能。 python中的模块分为内置模块与第三方模块。 常用的模块:os,sys os模块函数 os.getcwd() 得到当前 阅读全文

posted @ 2023-03-05 21:40 生活旅行家 阅读(145) 评论(0) 推荐(0) 编辑

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