![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
悟空学python
知识就是力量,坚持能坚持的¥@
展开
-
python 使用you-get批量下载视频
使用需要的python 库:requests,lxml,you-get主要目的:体验you-get 的强大代码还有很多不足的地方,容易被反爬import requestsfrom lxml import etree#xpathimport os#导入需要的3个库def get_url_list(): url='https://v.qq.com/x/cover/a6nzna6g...原创 2018-12-14 21:32:22 · 4753 阅读 · 0 评论 -
python 处理pdf文本
使用pdfminer转pdf文件from pdfminer.pdfinterp import PDFTextExtractionNotAllowedfrom pdfminer.pdfparser import PDFParserfrom pdfminer.pdfparser import PDFPagefrom pdfminer.pdfparser import PDFDocumentf...转载 2019-07-07 15:23:22 · 610 阅读 · 0 评论 -
python time模块
time 时间模块import time#1.time() 获取本地时间res=time.time()print(res)#2.mktime() 通过(时间元组)获取时间戳#(参数是时间元组)ttp=(2001,10,1,11,8,30,0,0,0)res=time.mktime(ttp)print(res)#3.localtime() 通过时间戳获取[时间元组]r...原创 2019-07-05 22:49:07 · 100 阅读 · 0 评论 -
math函数常用操作
import mathmath函数#math.方法()来调用math模块当中的方法或者属性#1.** ceil() 向上取整 ceil 天花板res=math.ceil(5.0002)print(res)# 6#2. floor() 向下取整 地板res=math.floor(6.9)print(res) #6#3. pow 计算一个数的n次方(结果为浮点数...转载 2019-07-05 17:47:37 · 1624 阅读 · 0 评论 -
json 模块 和 pickle 模块
json模块序列化和反序列化操作 dumps 和loadsimport jsonstr1=“123”res=json.dumps(str1)print(res)res2=json.loads(res)print(res)可以序列化的类型: Number:int bool float容器:str tuple list dict...原创 2020-04-21 00:16:02 · 131 阅读 · 0 评论 -
os 模块常用命令
### os模块import os#1.在系统中执行命令os.system(“ifconfig”)#2.popen() 执行系统命令返回对象通过read读取字符串result=os.popen(“ifconfig”).read()print(result)#3.listdir() 获取指定文件夹中所有内容的名称列表result=os.listdir(".")print(res...转载 2019-07-04 22:50:20 · 930 阅读 · 0 评论 -
tarfile 压缩文件操作
import tarfileimport os[os.mkdir(“ceshi0%d”%x)for x in range(0,6) ]#os.mkdir(“ceshi00”)#os.mkdir(“ceshi01”)#os.mkdir(“ceshi02”)#os.mkdir(“ceshi03”)#os.mkdir(“ceshi04”)#os.mkdir(“ceshi05”)1.压缩...原创 2019-07-04 18:00:49 · 1754 阅读 · 0 评论 -
zipfile压缩文件
import zipfile #导入压缩文件包1.文件压缩#创建压缩文件对象zf = zipfile.ZipFile(“压缩文件名”,mode=“w”,enconding=“utf-8”)#压缩文件zf.write(“要压缩的文件”,“压缩后的名字”)#关闭压缩文件对象zf.close()#2.文件解压 extract extractallzf=zipfile.ZipFil...原创 2019-07-04 17:13:08 · 810 阅读 · 0 评论 -
set()和dict 集和 和 字典的相关操作
dict字典的相关操作一 增加方法一:dic={}dic[k]=v方法二: dic={} listvar=["a","b"] {}.fromkeys(listvar,[]) 使用update dic2={1:2,2:3} dic.update(dic2) #若存在相同的键,dic的键被替换二 删除dic={“a”:1,“b”:2,“...转载 2019-06-28 18:13:56 · 269 阅读 · 0 评论 -
变量的缓存机制
python各个数据类型的缓存机制1.Number类型的数据int类型: -5~正无群的id地址相同float类型:非负数的id相同bool :值相同即可complex:永远都不相同,除了只有虚数部分的id相同2.容器类型数据空元组的id的数据id相同字符串相同的id 数据id相同...原创 2019-06-28 15:01:10 · 313 阅读 · 0 评论 -
bool为假的十种情况类型
python中bool类型为假的始终情况int 整型 0float 浮点型 0.0complex 复数 0jtuple 元组()dict 空字典 {}set 空集合 set()list 空列表 []False bool值为FalseNoneNone是一个特殊的常量。 None和False不同。 None不是0。 None不是空字符串。 None和任何其他的数...转载 2019-06-28 14:50:39 · 620 阅读 · 0 评论 -
python list 的常用操作
字符串的常用操作# isalpha1.判断字符串时有字母或者汉字组成strvar="I love python"res=strvar.isalpha()#由于字符串包含空格,返回值,判断后的返回值时Falseprint(res)#startswith 和isendswith2. 判断字符串以什么字符开始和结尾strvar="ilovepython"print(strvar....原创 2019-06-24 21:26:18 · 147 阅读 · 0 评论 -
函数def func (*args,**kwargs)
函数def时候,参数的顺序:普通形参<默认实参<普通收集参数<命名关键字参数<关键字收集参数*args-> 普通收集参数**kwargs—> 关键字收集参数集定义函数时,def func(*args,**kwargs)args这个参数负责收集没人要的普通参数,构成一个元组(tuple)kwargs这个参数负责收集关键字参数,构成一个字典(d...原创 2020-04-21 00:17:29 · 1688 阅读 · 0 评论 -
python 简单的 用户注册登陆
注册功能#实现注册功能while 1: dic={} with open("regit.txt", mode='r+', encoding="utf-8")as fp: res = fp.read() #username 注册的用户名 username=input("请输入您的用户名:").strip() #判断用户名是否重复 temp="'username': '{}',...原创 2019-06-22 14:39:39 · 485 阅读 · 0 评论 -
ubuntu国内源地址
国内源:清华:https://pypi.tuna.tsinghua.edu.cn/simple阿里云:http://mirrors.aliyun.com/pypi/simple/中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/华中理工大学:http://pypi.hustunique.com/山东理工大学:http://pypi.sdutli...原创 2019-08-14 11:49:42 · 1577 阅读 · 0 评论