随笔分类 -  Python在线

记录Python学习的点滴,以使自己能更好的梳理进步,也为道友提供借鉴!
python运行快捷键
摘要: 阅读全文

posted @ 2021-01-25 17:22 ybl20000418 阅读(52) 评论(0) 推荐(0)

python sdnu校园网模拟登陆
摘要:# _*_ coding::utf_8 _*_ import urllib.request import urllib.parse post_url='http://192.168.255.195:8080/Control' form_data={ 'id': '2000', 'strAccount': '18765888179', 'strPassword': '123123', 's... 阅读全文

posted @ 2019-10-20 20:06 ybl20000418 阅读(405) 评论(0) 推荐(0)

pip 安装命令
摘要:在使用pip安装时如果不对pip进行设置,pip链接网站可能会到国外网址,因为墙的存在pip出现连接超时 我们用这个命令就可以解决 pip install numpy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com 此外还有其他原地址 通过几次pip的使用,对于默认的pip源的速度实在无法忍受... 阅读全文

posted @ 2019-10-07 20:00 ybl20000418 阅读(339) 评论(0) 推荐(0)

百度贴吧爬虫小程序源码
摘要:# _*_ coding::utf_8 _*_ import urllib.request import urllib.parse import os url='http://tieba.baidu.com/f?' start=int(input("请输入开始页码:")) end=int(input("请输入结束页码:")) name=input("请输入搜索贴吧的名字:") name1=url... 阅读全文

posted @ 2019-09-29 19:27 ybl20000418 阅读(182) 评论(0) 推荐(0)

ajax get post
摘要:在post请求中直接将表单数据data转移之后不用拼接,在请求数据的时候在尾部加入即可。 阅读全文

posted @ 2019-09-28 17:49 ybl20000418 阅读(82) 评论(0) 推荐(0)

爬取豆瓣电影
摘要:代码 # _*_ coding::utf_8 _*_ import re import urllib.parse import urllib.request url='https://movie.douban.com/j/search_subjects?type=movie&tag=%E7%A7%91%E5%B9%BB&sort=rank&' # page=int(input("请输入要查询的... 阅读全文

posted @ 2019-09-24 22:13 ybl20000418 阅读(111) 评论(0) 推荐(0)

post get 请求 headers注释哪些
摘要:post和get #post请求fomdata=urllib.parse.urlencode(fomdata).encode() request=urllib.request.Request(url=url,headers=headers) response=urllib.request.urlopen(request,fomdata) print(response.read().decode() 阅读全文

posted @ 2019-09-24 21:36 ybl20000418 阅读(692) 评论(0) 推荐(0)

post请求get请求
摘要:post请求 # _*_ coding::utf_8 _*_ import urllib.request import urllib.parse # 开始url、(word、data在一块)headers请求头 post_url='https://fanyi.baidu.com/sug' word=input('输入查询单词:') form_data={ 'kw':word, } he... 阅读全文

posted @ 2019-09-23 22:07 ybl20000418 阅读(130) 评论(0) 推荐(0)

UA伪装
摘要:# _*_ coding::utf_8 _*_ import urllib.request import urllib.parse url="https://www.bilibili.com/" headers={ 'User-Agent':'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (K 阅读全文

posted @ 2019-09-22 21:40 ybl20000418 阅读(139) 评论(0) 推荐(0)

urllib.request encode()/decode()
摘要:urllib.request urlopen(url)#直接打开相应的url urlretrieve(url,image_path)#打开url直接将图片存储,后面为图片存储地址 encode()/decode()小括号里面不写参数,默认是utf8,写只能写gbk。 阅读全文

posted @ 2019-09-21 21:27 ybl20000418 阅读(325) 评论(0) 推荐(0)

urllib.parse quote/unquate/urlencode
摘要:quote :url编码函数,将中文进行转化为%xxxx # _*_ coding::utf_8 _*_ import urllib.request import urllib.parse url='http://baidu.com/index.html?name=杨洪&pwd=123456' ret=urllib.parse.quote(url) ret1=urllib.parse.unqu... 阅读全文

posted @ 2019-09-21 21:23 ybl20000418 阅读(334) 评论(0) 推荐(0)

python 爬取图片
摘要:得到url response=urllib.request.urlopen(url)打开获得的url response.read().decode()# decode()将读出的信息以二进制字节形式打开, 将获得的文件输出,有方法一,方法二、方法三可以直接进行传数 方法一: with open(r' 阅读全文

posted @ 2019-09-21 20:15 ybl20000418 阅读(111) 评论(0) 推荐(0)

huancun
摘要:# _*_ utf-8 _*_: # author:Administrator list1=[] import random for i in range(10): a=random.randint(0,100) list1.append(a) print(list1) for j in range(1,10): print(list1[j]," ",j) index=j-1 current=li 阅读全文

posted @ 2019-09-18 22:23 ybl20000418 阅读(93) 评论(0) 推荐(0)

python for 1开始,倒序输出
摘要:python中的range函数取反序有两种方式 第一种,先构建一个列表,然后对列表中的元素进行反转。 例如:a=range(5) for i in reversed(a): print(i) #4 3 2 1 0 第二种,是利用range()函数本身的特点来进行反序。 例如:for i in ran 阅读全文

posted @ 2019-09-18 22:06 ybl20000418 阅读(3832) 评论(0) 推荐(0)

python列表(可重复可类型不同)元组一旦确定不可更改
摘要::想要创建空集合,你必须使用 set() 而不是 {} ,后者用于创建空字典 在单个 dictionary 里,dictionary 的值并不需要全都是同一数据类型,可以根据需要混用和匹配。 元组中的元素也可以是不同类型的数据: 阅读全文

posted @ 2019-09-17 18:39 ybl20000418 阅读(697) 评论(0) 推荐(0)

Python异常处理
摘要:基本结构: try: 被检测的代码块 except 异常类型: try中一旦检测到异常,就执行这个位置的逻辑 单分支结构: #单分支只能用来处理指定的异常情况,如果未捕获到异常,则报错 try: a except NameError as e: #我们可以使用except与as+变量名 搭配使用,打 阅读全文

posted @ 2019-09-10 14:39 ybl20000418 阅读(110) 评论(0) 推荐(0)

python抽象类
摘要:python中没有接口类型 抽象类的本质还是类,指的是一组类的相似性,包括数据属性(如all_type)和函数属性(如read、write),而接口只强调函数属性的相似性。抽象类是一个介于类和接口直接的一个概念,同时具备类和接口的部分特性,可以用来实现归一化设计 在Python3中引入了abc模块,通过@abc.abstractmethod可以更加简洁地使用抽象类,抽象方法。 抽象类的方法必须在子 阅读全文

posted @ 2019-09-09 21:40 ybl20000418 阅读(134) 评论(0) 推荐(0)

python传参*和**的区别
摘要:参考文章:https://www.cnblogs.com/gongyu2018/p/8805183.html 2019-09-09 21:17:54 阅读全文

posted @ 2019-09-09 21:18 ybl20000418 阅读(502) 评论(0) 推荐(0)

python 多重继承构造函数调用顺序
摘要:实例代码 class Person(object): def __init__(self, name, age): self.name = name self.age = age print("父类构造函数") def talk(self): print("person is talking.... 阅读全文

posted @ 2019-09-09 15:22 ybl20000418 阅读(1111) 评论(0) 推荐(0)

python format 格式化输出博文集锦
摘要:https://www.cnblogs.com/yz-lucky77/p/10703761.htmlhttps://blog.csdn.net/programmer_yf/article/details/80539999 阅读全文

posted @ 2019-09-09 15:12 ybl20000418 阅读(131) 评论(0) 推荐(0)

导航