大数据实训(爬取前程无忧利用hive、sqoop分析)

2023-10-21 23:59

本文主要是介绍大数据实训(爬取前程无忧利用hive、sqoop分析),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、总体要求

利用python编写爬虫程序,从招聘网站上爬取数据,将数据存入到MongoDB数据库中,将存入的数据作一定的数据清洗后做数据分析,最后将分析的结果做数据可视化。

二、环境

hadoop:https://editor.csdn.net/md/?articleId=106674836

hive:链接:https://pan.baidu.com/s/1dBVZN1iOB8Okqv8lD_h_Eg

提取码:mjx4

zookeeper:https://editor.csdn.net/md/?articleId=106788153

flume:https://editor.csdn.net/md/?articleId=106695309

sqoop:https://editor.csdn.net/md/?articleId=106837578

三、爬取字段(前程无忧、应届生)

1、具体要求:职位名称、薪资水平、招聘单位、工作地点、工作经验、学历要求、工作内容(岗位职责)、任职要求(技能要求)。
(1)新建一个项目:scrapy startproject pawuyijob
(2)生成一个spider文件:scrapy genspider wuyi wuyi.com
结构如下:

在这里插入图片描述
(3)修改settings.py

BOT_NAME = 'pawuyijob'SPIDER_MODULES = ['pawuyijob.spiders']
NEWSPIDER_MODULE = 'pawuyijob.spiders'
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36'
DOWNLOAD_DELAY = 0.5
ITEM_PIPELINES = {'pawuyijob.pipelines.PawuyijobPipeline': 300,
}

(4)编写items.py
代码如下:

import scrapyclass PawuyijobItem(scrapy.Item):# define the fields for your item here like:# name = scrapy.Field()work_place = scrapy.Field()  # 工作地点company_name = scrapy.Field()  # 公司名称position_name = scrapy.Field()  # 职位名称company_info = scrapy.Field()  # 公司信息work_salary = scrapy.Field()  # 薪资情况release_date = scrapy.Field()  # 发布时间job_require = scrapy.Field()  # 职位信息contact_way = scrapy.Field()  # 联系方式education = scrapy.Field()  # 学历work_experience = scrapy.Field()#工作经验pass

5)编写spiders文件
我们最关键的东西就是能够把xpath找正确,很明显我们能看见每行数据都在这个标签中,我们可以写个循环

在这里插入图片描述
(6)还有我们可以按住ctrl+f,看我们的xpath是否匹配到了
在这里插入图片描述
(7)详情页的url
在这里插入图片描述
(7)下一页的url:
在这里插入图片描述
(8)spider代码如下:

# -*- coding: utf-8 -*-
import scrapyfrom pawuyijob.items import PawuyijobItemclass WuyiSpider(scrapy.Spider):name = 'wuyi'allowed_domains = ['51job.com']start_urls =['https://search.51job.com/list/000000,000000,0130%252C7501%252C7506%252C7502,01%252C32%252C38,9,99,%2520,2,1.html?lang=c&stype=&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&providesalary=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&line=&specialarea=00&from=&welfare=']def parse(self, response):#每条数据存放的xpathnode_list = response.xpath("//div[@id='resultList']/div[@class='el']")# 整个for循环结束代表 当前这一页已经爬完了, 那么就该开始爬取下一页for node in node_list:item = PawuyijobItem()# 职位名称item["position_name"] = node.xpath("./p/span/a/@title").extract_first()# 公司信息item["company_name"] = node.xpath("./span[@class='t2']/a/@title").extract_first()# 工作地点item["work_place"] = node.xpath("./span[@class='t3']/text()").extract_first()# 薪资情况item["work_salary"] = node.xpath("./span[@class='t4']/text()").extract_first()# 发布时间item["release_date"] = node.xpath("./span[@class='t5']/text()").extract_first()#详情页的urldetail_url = node.xpath("./p/span/a/@href").extract_first()yield scrapy.Request(url=detail_url, callback=self.parse_detail, meta={"item": item})#下一页next_url = response.xpath("//div[@class='p_in']//li[@class='bk'][2]/a/@href").extract_first()#如果没有详情页的url我们就返回不再执行if not next_url:returnyield scrapy.Request(url=next_url, callback=self.parse)def parse_detail(self, response):item = response.meta["item"]# 职位信息item["job_require"] = response.xpath("//div[@class='bmsg job_msg inbox']/p/text()").extract()# 联系方式item["contact_way"] = response.xpath("//div[@class='bmsg inbox']/a/text()").extract()# 公司信息item["company_info"] = response.xpath("//div[@class='tmsg inbox']/text()").extract()# 学历item["education"] = response.xpath("//div[@class='tHeader tHjob']/div/div/p[2]/text()").extract()[2]# 工作经验item["work_experience"] = response.xpath("//div[@class='tHeader tHjob']/div/div/p[2]/text()").extract()[1]yield item

(9)我们需要把数据存储到mongodb,需要编写我们的pipelines.py

from pymongo import MongoClientclass PawuyijobPipeline(object):def open_spider(self, spider):self.db = MongoClient('localhost', 27017).pawuyijob_db#连接mongodb数据库self.collection = self.db.pawuyijob_collection#连接表def process_item(self, item, spider):self.collection.insert_one(dict(item))return item

(10)我这里是分别存储数据采集、数据开发、数据分析这些表的
运行scapy crawl wuyi
我们来看一下mongodb里面的数据是怎样的

在这里插入图片描述
(11)每个数据库中表的数据是怎样的
在这里插入图片描述
(12)mongodb导出数据命令(其中-d后面是数据库 -c后面是表 -o后面跟要保存的路径)

mongoexport  -d  pawuyijobkaifa_db  -c  pawuyijobkaifa_collection      --type=json  -o  D:\cjdata1.json

四、具体要求:将爬取的数据存储到hdfs上。利用flume收集日志。若整个过程利用mangdb转hdfs则为

1.正确搭建hadoop平台:
在这里插入图片描述
2.正确选择flume协议传输形式
tail-hdfs.conf
配置文件如下:

#name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -F /home/data/job.txt #监控data目录下
a1.sources.r1.channels = c1# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.channel = c1
a1.sinks.k1.hdfs.path =hdfs://hadoop01:9000/flume/tailout/%y-%m-%d/%H-%M/ #把数据收集到hdfs目录下
a1.sinks.k1.hdfs.filePrefix = log-
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
a1.sinks.k1.hdfs.rollInterval = 3
a1.sinks.k1.hdfs.rollSize = 20
a1.sinks.k1.hdfs.rollCount = 5
a1.sinks.k1.hdfs.batchSize = 1
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#生成的文件类型,默认是Sequencefile,可用DataStream,则为普通文本
a1.sinks.k1.hdfs.fileType = DataStream# Use a channel which buffers events in memory
a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100

3、运行:

../bin/flume-ng agent -c conf -f tail-hdfs.conf -name a1 -Dflume.root.logger=DEBUG,console

在这里插入图片描述
4、查看一下hdfs上面的文件
在这里插入图片描述

5.能将数据存储到hdfs
命令:

hdfs dfs -put /home/tmpdata/job.txt /user

在这里插入图片描述

五、(1)具体要求(要求:1、利用hive进行分析,2、将hive分析结果利用sqoop技术存储到mysql数据库中,并最后显示分析结果。):

1、分析“数据分析”、“大数据开发工程师”、“数据采集”等岗位的平均工资、最高工资、最低工资,并作条形图将结果展示出来;
启动hive:

在这里插入图片描述
2.创建一个数据库:

create database job;
use job;

3.创建一个表(表里面要包含数据里面的字段):

create table job(id string,position_name string,company_name string,work_place string,work_salary string,release_date string,job_require string,contact_way string,company_info string,education string,work_experience string)row format delimited fields terminated by ',' 
stored as textfile ;
create table job8(id string,position_name string,company_name string,work_place string,work_salary string,release_date string,education string,work_experience string)row format delimited fields terminated by ',' 
stored as textfile ;

4.将数据从hdfs上面传入到表中


load data inpath 'hdfs://hadoop01:9000/user/job.txt' into table job;

在这里插入图片描述
5.我们需要把这个表里面的position_name,work_salary数据拿取出来并且去掉引号

create table job1 as select regexp_replace(position_name,'"','')as position_name,regexp_replace(work_salary,'"','')as work_salary from job;

查询一下结果:

select * from job;

结果如下:
在这里插入图片描述
6.把该position_name,work_salary数据进行去重:

create table job2 as select position_name,work_salary from job1 group by position_name,work_salary;

7.将数据分析的position_name,work_salary全部字段拿取出来:

create table job3 as select position_name,work_salary from job2 where position_name like '%数据分析';

在这里插入图片描述
8.数据采集:创建一个表job4里面有position_name,work_salary字段

create table job4 as select position_name,work_salary from job2 where position_name like '%数据采集%';

9.大数据开发:创建一个表job5里面有position_name,work_salary字段

create table job5 as select position_name,work_salary from job2 where position_name like '%大数据开发%';

在这里插入图片描述
10.创建一个只有work_salary分析的表(数据开发):

create table fx as select work_salary from job3;

在这里插入图片描述
11.将上面的表里面的引号去掉work_salary:

create table fx1 as select regexp_replace(work_salary,'work_salary:','')as work_salary from fx;

在这里插入图片描述
12.将里面的空值换掉

create table fx2 as select regexp_replace(work_salary,'null','')as work_salary from fx2;
insert overwrite table fx1 select * from fx1 where work_salary is not null;

效果图:
在这里插入图片描述
13.去重:

create table fx2 as select work_salary from fx1 group by work_salary;

在这里插入图片描述

14.去除数据里面的null值

insert overwrite table fx1 select * from fx1 where work_salary is not null;

15.创建一个表fx2用来保存去除后的里面的work_salary:

create table fx2 as select regexp_replace(work_salary,'work_salary:','')as work_salary from fx1;

16.创建一个表去掉重复的数据:

create table fx4 as select * from fx3 group by work_salary;

17.得到按年的工资:

create table cj_y as select * from fx4 where work_salary like '%年';

18.得到按月的工资:

create table cj_m as select * from fx4 where work_salary like '%月';

19.去掉月

create table cj_y1 as select regexp_replace(work_salary,'/年','')as work_salary from cj_y;create table cj_m1 as select regexp_replace(work_salary,'/月','')as work_salary from cj_m;

20.得到千的工资分别创建cj_m2,cj_mw2,cj_y2表,让里面只有数字

create table cj_m2 as select regexp_replace(work_salary,'千','')as work_salary from cj_m1 where work_salary like '%千';
create table cj_mw2 as select regexp_replace(work_salary,'万','')as work_salary from cj_m1 where work_salary like '%万';
create table cj_y2 as select regexp_replace(work_salary,'万','')as work_salary from cj_y1 where work_salary like '%万';

21.创建表分别为cj_m3,cj_mw3,cj_y3 切分表里面的数据,方便后面的计算

create table cj_m3 as select split(work_salary,'-')[0] as min,split(work_salary,'-')[1] as max from cj_m2;create table cj_mw3 as select split(work_salary,'-')[0] as min ,split(work_salary,'-')[1] as max from cj_mw2;create table cj_y3 as select split(work_salary,'-')[0] as min ,split(work_salary,'-')[1] as max from cj_y2;

22.分别创建表,cj_m4, cj_mw4得到平均值和1000

create table cj_m4 as select min*1000 as min,max*1000 as max,(min+max)/2*1000 as avg from cj_m3;
create table cj_mw4 as select min*10000 as min,max*10000 as max,(min+max)/2*10000 as avg from cj_mw3;

23.创建一个表cj_y4,除以12求到每个月的

create table cj_y4 as select min*10000/12 as min,max*10000/12 as max,(min+max)/2*10000/12 as avg from cj_y3;

24.放到一个表里

insert into cj_y4 select * from cj_m4;
insert into cj_y4 select * from cj_mw4;

25.得到数据

create table cj_result as select min(min) as min,max(max) as max,avg(avg) as avg from cj_y4;

查看hive表的位置

show create table shuju10;
'hdfs://hadoop01:9000/user/hive/warehouse/job.db/表名'

26.在mysql建立相应的表
在这里插入图片描述
27.利用sqoop将hive数据导出到mysql

sqoop export --connect "jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8" --username root --password 123456 --table fx_result --fields-terminated-by '\001' --export-dir '/user/hive/warehouse/job.db/fx_result';

在这里插入图片描述
28.查看mysql里面的表是否有数据
在这里插入图片描述

29.利用sqoop将hive数据导入到mysql:

sqoop export --connect "jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8" --username root --password 123456 --table kf_result --fields-terminated-by '\001' --export-dir '/user/hive/warehouse/job.db/kf_result';

在这里插入图片描述
30.分别查看mysql里面的数据:
在这里插入图片描述
条形图如下:
代码如下:

# coding=gbk
import re
from pyecharts import options as opts
from pyecharts.charts import Bar
from pymongo import MongoClient
import pandas as pd
import numpy as np
post_list=["数据分析", "大数据开发工程师", "数据采集"]
avg_list = [12019.00269541779, 18243.627450980395, 9613.38028169014]
max_list = [50000.0 , 130000.0, 40000.0 ]
min_list = [833.3333333333334, 1500.0, 1500.0]
bar = (Bar(init_opts=opts.InitOpts(width="1600px", height="900px"),).set_global_opts(# 设置标题信息title_opts=opts.TitleOpts(title="行业薪资", subtitle="单位  元/月"),# 设置X轴倾斜值xaxis_opts=opts.AxisOpts(axislabel_opts={"rotate": 30}),# 显示工具箱toolbox_opts=opts.ToolboxOpts())# 关联数据.add_xaxis(post_list)  # 确定x轴上要显示的内容# 确定y轴上要显示的内容.add_yaxis('平均工资', avg_list).add_yaxis('最高工资', max_list).add_yaxis('最低工资', min_list)
)
bar.render("行业薪资.html")

在这里插入图片描述
2.分析“数据分析”、“大数据开发工程师”、“数据采集”等大数据相关岗位在成都、北京、上海、广州、深圳的岗位数,并做饼图将结果展示出来

1.分别查询数据分析在成都、北京、上海、广州、深圳的岗位数

create table fxcd as  select count(*) cd from job where position_name like '%数据分析%' and work_place like '%成都%';

在这里插入图片描述
分别创建表,fxcd,fxbj,fxgz,fxsh,求出数据分析在成都、北京、广州、上海、深圳的岗位数

create table fxbj as  select count(*) bj from job where position_name like '%数据分析%' and work_place like '%北京%';create table fxgz as  select count(*) gz from job where position_name like '%数据分析%' and work_place like '%广州%';create table fxsh as  select count(*) sh from job where position_name like '%数据分析%' and work_place like '%上海%';create table fxsz as  select count(*) sz from job where position_name like '%数据分析%' and work_place like '%深圳%';

把上面标的数据放在一个表中

insert into fxsh select * from fxgz;
insert into fxsz select * from fxgz;
insert into fxcd select * from fxgz;
insert into fxbj select * from fxgz;

在这里插入图片描述
2.饼图如下:
代码如下:

import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
sd = [42,97,245,187,136]
labels = ['成都','北京','上海','广州','深圳']plt.pie(x=sd,labels=labels,autopct='%.1f%%')
plt.title("数据分析")
plt.show()

在这里插入图片描述
分别创建表,cjcd,cjbj,cjgz,cjsh,求出数据分析在成都、北京、广州、上海、深圳的岗位数

create table cjcd as  select count(*) cd from job where position_name like '%数据分析%' and work_place like '%成都%';create table cjbj as  select count(*) bj from job where position_name like '%数据采集%' and work_place like '%北京%';create table cjgz as  select count(*) gz from job where position_name like '%数据采集%' and work_place like '%广州%';create table cjsh as  select count(*) sh from job where position_name like '%数据采集%' and work_place like '%上海%';create table cjsz as  select count(*) sz from job where position_name like '%数据采集%' and work_place like '%深圳%';

查看mysql里面的表
在这里插入图片描述
分别创建表,kfcd,kfbj,kfgz,kfsh,求出数据开发在成都、北京、广州、上海、深圳的岗位数

create table kfcd as  select count(*) cd from job where position_name like '%数据分析%' and work_place like '%成都%';create table kfbj as  select count(*) bj from job where position_name like '%数据采集%' and work_place like '%北京%';create table kfgz as  select count(*) gz from job where position_name like '%数据采集%' and work_place like '%广州%';create table kfsh as  select count(*) sh from job where position_name like '%数据采集%' and work_place like '%上海%';create table kfsz as  select count(*) sz from job where position_name like '%数据采集%' and work_place like '%深圳%';

3.数据采集饼图:
代码如下:

import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
sd = [42,25,22,12,16]
labels = ['成都','北京','上海','广州','深圳']plt.pie(x=sd,labels=labels,autopct='%.1f%%')
plt.title("数据采集")
plt.show()

在这里插入图片描述
4.数据开发,mysql里面的结果如下
在这里插入图片描述
5.数据开发饼图如下:
代码如下:

import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
sd = [42,25,22,12,16]
labels = ['成都','北京','上海','广州','深圳']plt.pie(x=sd,labels=labels,autopct='%.1f%%')
plt.title("数据开发")
plt.show()

在这里插入图片描述
6.在mysql中创建相应的表
在这里插入图片描述
在这里插入图片描述
利用sqoop将hive数据导出到mysql

sqoop export --connect "jdbc:mysql://localhost:3306/test?chaocalhost:3306/test?characterEncoding=UTF-8" --username root --password 123456 --table kfbj --fields-terminated-by '\001' --export-dir '/user/hive/warehouse/job.db/kfbj';

在这里插入图片描述

3、分析大数据相关岗位1-3年工作经验的薪资水平(平均工资、最高工资、最低工资),并做出条形图展示出来;
(1).先创建一个表查询position_name是大数据岗位的信息,里面有work_salary,work_experience字段

create table sj12 as select position_name,work_salary,work_experience from job8 where position_name like '%大数据%';

(2).在创建一个表,查询里面工作经验1-3年的模糊查询

create table sj13 as select work_salary,work_experience from sj13 where work_experience like '%1年经验%' or work_experience like '%2年经验%' or work_experience like '%3年经验%' or work_experience like '%1-2年经验%' or work_experience like '%1-3年经验%';

(3)再创建一个表用来存放work_salary字段

create table sj14 as select work_salary from sj13;

(4)去掉里面的work_salary让里面只有数字

create table sj15 as select regexp_replace(work_salary,'"work_salary"','')as work_salary from sj14;

(5)效果图如下:
在这里插入图片描述

create table sj15 as select regexp_replace(work_salary,'"','')as work_salary from sj14;create table sj16 as select regexp_replace(work_salary,'work_salary:','')as work_salary from sj14;

(6)去掉数据里面的空值

insert overwrite table sj14 select * from sj14 where work_salary is not null;

在这里插入图片描述
(7)最后饼图:
代码如下:

# coding=gbk
import re
from pyecharts import options as opts
from pyecharts.charts import Bar
from pymongo import MongoClient
import pandas as pd
import numpy as np
post_list=["数据分析", "大数据开发工程师", "数据采集"]
avg_list = [0.96, 1.28, 1.10]
max_list = [2.5, 6, 1.2 ]
min_list = [1.2, 1, 1]
bar = (Bar(init_opts=opts.InitOpts(width="1600px", height="900px"),).set_global_opts(# 设置标题信息title_opts=opts.TitleOpts(title="行业薪资", subtitle="单位  万元/月"),# 设置X轴倾斜值xaxis_opts=opts.AxisOpts(axislabel_opts={"rotate": 30}),# 显示工具箱toolbox_opts=opts.ToolboxOpts())# 关联数据.add_xaxis(post_list)  # 确定x轴上要显示的内容# 确定y轴上要显示的内容.add_yaxis('平均工资', avg_list).add_yaxis('最高工资', max_list).add_yaxis('最低工资', min_list)
)
bar.render("数据行业薪资.html")

在这里插入图片描述
**
(4)分析大数据相关岗位几年需求的走向趋势,并做出折线图展示出来;

**
创建一个表用来存放position_name,release_date

create table tm as select position_name,release_date from job8;

查询大数据相关岗位的信息:

create table tm1 as select * from tm where position_name like '%大数据%';

创建一个只有日期的字段的表

create table tm2 as select release_date from tm1;
create table tm4 as select regexp_replace(position_name,'"','')as position_name,regexp_replace(release_date,'"','')as release_date from tm1;
 create table tm5 as select release_date from tm4;

去掉release_date:字段

create table tm6 as select regexp_replace(release_date,'release_date:','')as release_date from tm5;

分割后得到月:

create table tm7 as select split(release_date,'-')[0] as release_date from tm6;

再来进行统计每个月有多少:

select release_date,count(*)from tm7 group by release_date;

效果图如下:
在这里插入图片描述
折线图
在这里插入图片描述

(5)在学习过程中遇到到错误,已经解决办法
博客:https://blog.csdn.net/weixin_44701462/article/details/107310856
https://blog.csdn.net/weixin_44701462/article/details/107201005

这篇关于大数据实训(爬取前程无忧利用hive、sqoop分析)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/257777

相关文章

慢sql提前分析预警和动态sql替换-Mybatis-SQL

《慢sql提前分析预警和动态sql替换-Mybatis-SQL》为防止慢SQL问题而开发的MyBatis组件,该组件能够在开发、测试阶段自动分析SQL语句,并在出现慢SQL问题时通过Ducc配置实现动... 目录背景解决思路开源方案调研设计方案详细设计使用方法1、引入依赖jar包2、配置组件XML3、核心配

Java NoClassDefFoundError运行时错误分析解决

《JavaNoClassDefFoundError运行时错误分析解决》在Java开发中,NoClassDefFoundError是一种常见的运行时错误,它通常表明Java虚拟机在尝试加载一个类时未能... 目录前言一、问题分析二、报错原因三、解决思路检查类路径配置检查依赖库检查类文件调试类加载器问题四、常见

Java注解之超越Javadoc的元数据利器详解

《Java注解之超越Javadoc的元数据利器详解》本文将深入探讨Java注解的定义、类型、内置注解、自定义注解、保留策略、实际应用场景及最佳实践,无论是初学者还是资深开发者,都能通过本文了解如何利用... 目录什么是注解?注解的类型内置注编程解自定义注解注解的保留策略实际用例最佳实践总结在 Java 编程

一文教你Python如何快速精准抓取网页数据

《一文教你Python如何快速精准抓取网页数据》这篇文章主要为大家详细介绍了如何利用Python实现快速精准抓取网页数据,文中的示例代码简洁易懂,具有一定的借鉴价值,有需要的小伙伴可以了解下... 目录1. 准备工作2. 基础爬虫实现3. 高级功能扩展3.1 抓取文章详情3.2 保存数据到文件4. 完整示例

使用Java将各种数据写入Excel表格的操作示例

《使用Java将各种数据写入Excel表格的操作示例》在数据处理与管理领域,Excel凭借其强大的功能和广泛的应用,成为了数据存储与展示的重要工具,在Java开发过程中,常常需要将不同类型的数据,本文... 目录前言安装免费Java库1. 写入文本、或数值到 Excel单元格2. 写入数组到 Excel表格

Python中的Walrus运算符分析示例详解

《Python中的Walrus运算符分析示例详解》Python中的Walrus运算符(:=)是Python3.8引入的一个新特性,允许在表达式中同时赋值和返回值,它的核心作用是减少重复计算,提升代码简... 目录1. 在循环中避免重复计算2. 在条件判断中同时赋值变量3. 在列表推导式或字典推导式中简化逻辑

python处理带有时区的日期和时间数据

《python处理带有时区的日期和时间数据》这篇文章主要为大家详细介绍了如何在Python中使用pytz库处理时区信息,包括获取当前UTC时间,转换为特定时区等,有需要的小伙伴可以参考一下... 目录时区基本信息python datetime使用timezonepandas处理时区数据知识延展时区基本信息

Qt实现网络数据解析的方法总结

《Qt实现网络数据解析的方法总结》在Qt中解析网络数据通常涉及接收原始字节流,并将其转换为有意义的应用层数据,这篇文章为大家介绍了详细步骤和示例,感兴趣的小伙伴可以了解下... 目录1. 网络数据接收2. 缓冲区管理(处理粘包/拆包)3. 常见数据格式解析3.1 jsON解析3.2 XML解析3.3 自定义

SpringMVC 通过ajax 前后端数据交互的实现方法

《SpringMVC通过ajax前后端数据交互的实现方法》:本文主要介绍SpringMVC通过ajax前后端数据交互的实现方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价... 在前端的开发过程中,经常在html页面通过AJAX进行前后端数据的交互,SpringMVC的controll

Pandas统计每行数据中的空值的方法示例

《Pandas统计每行数据中的空值的方法示例》处理缺失数据(NaN值)是一个非常常见的问题,本文主要介绍了Pandas统计每行数据中的空值的方法示例,具有一定的参考价值,感兴趣的可以了解一下... 目录什么是空值?为什么要统计空值?准备工作创建示例数据统计每行空值数量进一步分析www.chinasem.cn处