上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 38 下一页
摘要: 这篇文章主要介绍了Python 列表(List) 的四种遍历方法实例 详解的相关资料,需要的朋友可以参考下 分别是:直接遍历对象 通过索引遍历 通过enumerate方法 通过iter方法。 使用Python遍历List四种方法代码如下: def text2(self): li = ['a', 'b 阅读全文
posted @ 2021-01-31 13:25 Bonnie_ξ 阅读(1560) 评论(0) 推荐(0) 编辑
摘要: 1、交换两个变量 # a = 4 b = 5 a,b = b,a # print(a,b) >> 5,4 让我们通过交换两个变量作为一个简单的开始。 此方法是最简单、最直观的方法之一,无需使用临时变量或应用算术操作即可编写。 2、多个变量赋值 a,b,c = 4,5.5,'Hello' #print 阅读全文
posted @ 2021-01-31 13:04 Bonnie_ξ 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 玩转正则表达式 本文中介绍的是主要是 3 个知识点: 正则表达式的相关知识 Python的中 re 模块,主要是用来处理正则表达式 一个利用 re 模块通过正则表达式来进行网页数据的爬取和存储 1、正则表达式 1.1 正则表达式及作用 正则表达式的英文是 regular expression,通常简 阅读全文
posted @ 2021-01-30 22:57 Bonnie_ξ 阅读(299) 评论(0) 推荐(0) 编辑
摘要: URL参数请求: import requests ''' URL Parameters 请求方式:URL参数 例如: 以get 方式请求http://httpbin.org/get?first_name=hello&last_name=word ''' # params={"first_name": 阅读全文
posted @ 2021-01-30 22:32 Bonnie_ξ 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 一、选取节点常用的路径表达式: 表达式 描述 实例 nodename 选取nodename节点的所有子节点 xpath(‘//div’) 选取了div节点的所有子节点 / 从根节点选取 xpath(‘/div’) 从根节点上选取div节点 // 选取所有的当前节点,不考虑他们的位置 xpath(‘/ 阅读全文
posted @ 2021-01-29 17:14 Bonnie_ξ 阅读(894) 评论(0) 推荐(0) 编辑
摘要: 标准选择器 可根据标签名、属性、内容查找文档 注意这里class 为python 的关键字 需要加入下划线_ find_all( name , attrs , recursive , text , **kwargs ) name html=''' <div class="panel"> <div c 阅读全文
posted @ 2021-01-29 09:47 Bonnie_ξ 阅读(1239) 评论(0) 推荐(0) 编辑
摘要: 实例: 匹配标签 匹配title标签 匹配网页的 <title></title> 标签,也就是网页的标题。 .*? 就是匹配1个或多个字符,也就是这里不能是空的。当加入括号的话,就是代表取值了 (.*?) import re import requests resp=requests.get("ht 阅读全文
posted @ 2021-01-28 10:27 Bonnie_ξ 阅读(561) 评论(0) 推荐(0) 编辑
摘要: 抓取天气 import requests from bs4 import BeautifulSoup # from pyecharts import Bar cities_temp = [] # 处理抓取页面 def parse_url(url): headers = {"User-Agent": 阅读全文
posted @ 2021-01-27 16:40 Bonnie_ξ 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 案例 import requests import os from requests.packages import urllib3 from pyquery import PyQuery as pq import re # 解析数据 import ssl os.chdir(r"E:/pics222 阅读全文
posted @ 2021-01-27 16:37 Bonnie_ξ 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 案例 from selenium import webdriver from selenium.webdriver.common.keys import Keys # 键盘按键操作 import time def get_goods(driver): try: goods = driver.find 阅读全文
posted @ 2021-01-27 16:32 Bonnie_ξ 阅读(137) 评论(0) 推荐(0) 编辑
上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 38 下一页