Python
qq_308452419
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python 日志输出配置模块
import logging # 日志模块 class Logger: ''' 文件日志及控制台日志输出配置 ''' def __init__(self, filename='logging.log', fileLevel = logging.INFO, consoleLevel = logging.INFO): self.filename = filename self.format = "%(asctime)s - [line:%.原创 2021-03-09 15:51:52 · 305 阅读 · 1 评论 -
破解js加密--python execjs库 执行js代码
import execjs import re import requests import time #测试url url = 'http://gaj.chifeng.gov.cn/default.php?mod=article&fid=230&s63642044_start=0' session = requests.session() #存储cookie respon...原创 2019-08-21 18:55:01 · 1161 阅读 · 0 评论 -
查找算法——二分法查找
#二分法查找 #前提:这个列表是有序的(已经排好序的)list0=[23,34,56,78,89] key=12 #设置初始区间值 min_index=0 max_index=len(list0)-1 #设置起始区间索引 mid_index=(min_index+max_index)//2 while list0[mid_index]!=key: if list0[mid_...原创 2018-04-20 22:57:20 · 233 阅读 · 0 评论 -
列表生成式
#列表生成式 list0=[1,2,3,4,5,6] #要求生成另一个表[1,4,9,16,25,36] new_list=[x*x for x in list0] print(new_list) #生成一个新的列表,列表中的元素是list0中的偶数 new_list=[x for x in list0 if x%2==0] print(new_list) #使用双层循环进行排列组合 list1=...原创 2018-04-23 09:04:08 · 211 阅读 · 0 评论 -
迭代器 iterable
#迭代器 iterable #----可以理解为另外一种遍历,使用forin可以遍历的类型都是可迭代的类型 Iterable from collections import Iterable #导入模块 from collections import Iterator #可以进行迭代的类型不一定是可迭代对象:Iterator #Iteratou 可迭代对象有一个特点:可以通过next获取下一个数据...原创 2018-04-23 09:03:08 · 189 阅读 · 0 评论 -
系统模块——OS
import os path=r"E:\学习资料\day09\notes\day09陈仁丽4组\sort_package\__pycache__" #列出子目录 #list_path=os.listdir(path) #print(list_path) #获取目录下的所有文件 用递归形式 def get_file(path): if os.path.exists(path)==Fals...原创 2018-04-23 09:02:31 · 233 阅读 · 0 评论 -
系统模块——OS
#os-系统模块 import os #获得操作系统的类型 print(os.name) #返回nt表示windows系统,posix---->inux和Mac #获取操作系统的详细信息,windows不支持 #print(os.uname) #获得系统指定变量下的内容---如:环境变量 print(os.environ.get("path")) #获取当前目录 . print(...原创 2018-04-23 09:01:38 · 174 阅读 · 0 评论 -
生成器的概念
#生成器:生成器的出现是来避免快速生成一批数据,瞬即占用内存过大的问题 #使用方式是当你需要数据的时候,去找生成器去拿,才会再内存中开辟空间 #列表生成式是快速的生成一个列表,内存中开辟相应的空间 #格式1:将列表中的[]换成() g=(x for x in range(100)) #获取数据next() print(next(g)) #如果生成器没有数据了,再去拿的话会报错 li=[1,3,5,...原创 2018-04-23 08:59:12 · 299 阅读 · 0 评论 -
字典的操作dict[]
#字典的操作 #与列表的对比:字典内存浪费比较多,查找和插入的速度特别快 dic={"语文":78,"数学":89} #添加另外一组键值对 dic["英语"]=75 print(dic) #根据key获得value,key必须存在,否则报错 value=dic["数学"] print(value) #另一个获得的方法,key不存在返回None value=dic.get("政治") print(v...原创 2018-04-23 08:57:44 · 425 阅读 · 0 评论 -
日历模块Calendar
#日历 import calendar #获取指定年的日历 res=calendar.calendar(2018,w=5,c=5) print(res) #获取指定月的日历 res_month=calendar.month(2018,4,w=3) print(res_month) #判定年是否是闰年 is_leap=calendar.isleap(2012) print(is_leap) #...原创 2018-04-23 08:56:13 · 311 阅读 · 0 评论 -
时间模块datetime
#时间模块 datetime import datetime #获取当前时间 cuttent_time=datetime.datetime.now() print(cuttent_time) #只获取年月日 cuttent_day=datetime.date.today() print(cuttent_day) #获取明天的日期 tomorrow=datetime.date.today()+d...原创 2018-04-23 08:55:13 · 165 阅读 · 0 评论 -
时间模块Time
#时间模块 #时间戳:表示从1970年1月1日凌晨开始按秒计算的一个偏移量 #1、获取当地时间的时间元组 import time local_time=time.localtime() #返回一个时间元组 print(local_time) #在时间元组中获得年份 year=local_time[0] print(year) #获取当前时间对应的时间戳 seconds=time.time()...原创 2018-04-23 08:53:18 · 195 阅读 · 0 评论
分享