使用Python开发桌面应用程序,python爬虫简历模板

self.button = QPushButton(“清洗附加选项”, self)
self.button.setFont(QFont(‘等线’, 11))
self.button.setGeometry(155, 60, 130, 30)
self.button.clicked.connect(self.button_clicked)

self.label_1_1 = QLabel(self)
self.label_1_1.setGeometry(290, 50, 700, 50)
self.label_1_1.setFont(QFont(“等线”, 14)) # 设置字体和字号
self.label_1_1.setVisible(False)

self.input_text = QLineEdit(self) # 创建一个输入框
self.input_text.setGeometry(155, 125, 130, 30)
self.input_text.setVisible(False)
self.input_text.setValidator(QIntValidator())

self.label_info = QLabel(“清洗指定列”, self) # 创建一个标签
self.label_info.setFont(QFont(‘等线’, 11))
self.label_info.setGeometry(155, 95, 130, 30) # 设置标签位置和大小
self.label_info.setVisible(False) # 初始时隐藏标签

self.label_info_1 = QLabel(“根据指定列去重”, self)
self.label_info_1.setFont(QFont(‘等线’, 11))
self.label_info_1.setGeometry(155, 155, 130, 30)
self.label_info_1.setVisible(False)

self.input_text_1 = QLineEdit(self)
self.input_text_1.setGeometry(155, 185, 130, 30)
self.input_text_1.setVisible(False)
self.input_text_1.setValidator(QIntValidator())

指示灯

self.red_light = QLabel(self)
self.red_light.setGeometry(10, 170, 20, 20)
self.red_light.setStyleSheet(“background-color: red”)
self.red_light.setVisible(False)

self.green_light = QLabel(self)
self.green_light.setGeometry(35, 170, 20, 20)
self.green_light.setStyleSheet(“background-color: green”)
self.green_light.setVisible(False)

self.line_horizontal_1 = SeparatorLine1(self)
self.line_horizontal_1.setGeometry(150, 225, 10000, 2)
self.line_horizontal_1.setVisible(False)

def button_clicked(self):
self.label_1_1.setText(‘(温馨提示,下方的输入框只能输入数字,以下参数非必须参数,可不填)’)
self.input_text.setVisible(not self.input_text.isVisible()) # 切换输入框的可见性
self.label_info.setVisible(self.input_text.isVisible())

self.input_text_1.setVisible(not self.input_text_1.isVisible()) # 切换输入框的可见性
self.label_info_1.setVisible(self.input_text_1.isVisible())

self.label_1_1.setVisible(not self.label_1_1.isVisible())
self.label_1_1.setVisible(self.label_1_1.isVisible())

def select_file(self): # 选择文件
file_dialog = QFileDialog()
file_path, _ = file_dialog.getOpenFileName(self, “选择文件”, “”, “All Files (*)”)
if file_path:
self.file_path = file_path

def save_file(self): # 保存文件
file_dialog = QFileDialog()
file_dialog.setWindowTitle(“另存为”) # 修改对话框标题
file_dialog.setNameFilters([“Text Files (.txt)", "CSV Files (.csv)”,
“Excel Files (*.xlsx .xls)", "JSON Files (.json .jsonl)"])
file_dialog.selectNameFilter("Excel Files (
.xlsx”)
if file_dialog.exec():
self.save_path = file_dialog.selectedFiles()[0]
if os.path.exists(self.save_path):

noinspection PyUnresolvedReferences

result = QMessageBox.warning(self, “警告”, “文件已存在,是否覆盖?”,
QMessageBox.Yes | QMessageBox.No)

noinspection PyUnresolvedReferences

if result == QMessageBox.Yes:
bag.Bag.save_excel([], self.save_path)
else:
self.save_path = ‘’
else:
bag.Bag.save_excel([], self.save_path)

def run(self): # 开始清洗
resp = judge(self.file_path)
total = len(resp)

def clean_1(ls, col_number, col_name):
self.red_light.setVisible(True)
result = []
for i, info in enumerate(tqdm(ls)):
mid = []
for value in info[col_number].split(‘\n’):
if re.sub(r’\s’, ‘’, value):
text = value.lstrip(‘,.?!;:,。?;:’)
text1 = text.strip()
text2 = emoji.replace_emoji(text1, replace=‘’)
mid.append(text2)
else:
pass
info[col_number] = ‘\n’.join(mid)
result.append(info)

更新进度条的值

progress = int((i + 1) / total * 100)
self.progress_bar.setValue(progress)
QApplication.processEvents() # 刷新界面

sign = []
new_result = [item for item in result if item[col_name] not in sign and not sign.append(item[col_name])]

self.red_light.setVisible(False)
self.green_light.setVisible(True)

if bool(self.save_path):
bag.Bag.save_excel(new_result, self.save_path)
else:
self.save_file()
bag.Bag.save_excel(new_result, self.save_path)
time.sleep(1)
self.green_light.setVisible(False)

def clean_2(ls, col_number):
self.red_light.setVisible(True)
result = []
for i, info in enumerate(tqdm(ls)):
mid = []
for value in info[col_number].split(‘\n’):
if re.sub(r’\s’, ‘’, value):
text = value.lstrip(‘,.?!;:,。?;:’)
text1 = text.strip()
text2 = emoji.replace_emoji(text1, replace=‘’)
mid.append(text2)
else:
pass
info[col_number] = ‘\n’.join(mid)
result.append(info)

progress = int((i + 1) / total * 100)
self.progress_bar.setValue(progress)
QApplication.processEvents() # 刷新界面

self.red_light.setVisible(False)
self.green_light.setVisible(True)

if bool(self.save_path):
bag.Bag.save_excel(result, self.save_path)
else:
self.save_file()
bag.Bag.save_excel(result, self.save_path)
time.sleep(1)
self.green_light.setVisible(False)

def clean_3(ls, col_name):
self.red_light.setVisible(True)
result = []
for i, info in enumerate(tqdm(ls)):
mid1 = []
for info1 in info:
mid = []
for value in info1.split(‘\n’):
if re.sub(r’\s’, ‘’, value):
text = value.lstrip(‘,.?!;:,。?;:’)
text1 = text.strip()
text2 = emoji.replace_emoji(text1, replace=‘’)
mid.append(text2)
else:
pass
mid1.append(‘\n’.join(mid))
result.append(mid1)

progress = int((i + 1) / total * 100)
self.progress_bar.setValue(progress)
QApplication.processEvents() # 刷新界面

sign = []
new_result = [item for item in result if item[col_name] not in sign and not sign.append(item[col_name])]

self.red_light.setVisible(False)
self.green_light.setVisible(True)

if bool(self.save_path):
bag.Bag.save_excel(new_result, self.save_path)
else:
self.save_file()
bag.Bag.save_excel(new_result, self.save_path)
time.sleep(1)
self.green_light.setVisible(False)

def clean_4(ls):
self.red_light.setVisible(True)
result = []
for i, info in enumerate(tqdm(ls)):
mid1 = []
for info1 in info:
mid = []
for value in info1.split(‘\n’):
if re.sub(r’\s’, ‘’, value):
text = value.lstrip(‘,.?!;:,。?;:’)
text1 = text.strip()
text2 = emoji.replace_emoji(text1, replace=‘’)
mid.append(text2)
else:
pass
mid1.append(‘\n’.join(mid))
result.append(mid1)

progress = int((i + 1) / total * 100)
self.progress_bar.setValue(progress)
QApplication.processEvents() # 刷新界面

self.red_light.setVisible(False)
self.green_light.setVisible(True)

if bool(self.save_path):
bag.Bag.save_excel(result, self.save_path)
else:
self.save_file()
bag.Bag.save_excel(result, self.save_path)

time.sleep(1)
self.green_light.setVisible(False)

additional_options = self.input_text.text() # 获取输入框的文本内容
additional_options_1 = self.input_text_1.text()
col_num = additional_options
tag_name = additional_options_1
“”“判断是否夹带清洗附加条件”“”
target = bool(col_num)
target_1 = bool(tag_name)

进度条

self.progress_bar.setVisible(True)
self.line_horizontal_1.setVisible(True)

处理异常

try:
if target and target_1: # 清洗指定列以及根据某某标签去重
clean_1(resp, int(col_num)-1, int(tag_name)-1)
elif target and not target_1: # 清洗子指定列,不去重
clean_2(resp, int(col_num)-1)
elif not target and target_1: # 清洗全文再根据某某列去重
clean_3(resp, int(tag_name)-1)
else: # 清洗全文,不去重
clean_4(resp)
QMessageBox.information(self, “完成”, “数据清洗完成”)
except Exception as e:
error_message = str(e)
QMessageBox.critical(self, “错误”, error_message)

压缩、解压

class CompressionDecompression(Layout):
def init(self):
super().init()
self.layout = QVBoxLayout()

self.file_path = None

self.button_compress = QPushButton(“压缩文件”, self)
self.button_compress.setFont(QFont(‘等线’, 11))
self.button_compress.setGeometry(10, 60, 130, 30)
self.button_compress.clicked.connect(self.on_button_clicked)

self.button_extract = QPushButton(“解压文件”, self)
self.button_extract.setFont(QFont(‘等线’, 11))
self.button_extract.setGeometry(10, 95, 130, 30)
self.button_extract.clicked.connect(self.on_button_clicked1)

def on_button_clicked(self):
selected_file = bool(self.file_path)
if selected_file:
extract_path = QFileDialog.getExistingDirectory(self, “另存为”)
if bool(extract_path):
unzip_file(selected_file, extract_path)
QMessageBox.information(self, ‘success’, ‘解压成功!’)
else:
QMessageBox.critical(self, ‘error’, ‘解压失败’)
else:
self.select_file()
extract_path = QFileDialog.getExistingDirectory(self, “另存为”)
if bool(extract_path):
unzip_file(self.file_path, extract_path)
QMessageBox.information(self, ‘success’, ‘解压成功!’)
else:
QMessageBox.critical(self, ‘error’, ‘解压失败’)

def on_button_clicked1(self):
selected_file = bool(self.file_path)
if selected_file:
extract_path = QFileDialog.getExistingDirectory(window, “选择文件夹”, options=QFileDialog.ShowDirsOnly)
if bool(extract_path):
self.compress_to_zip(selected_file, extract_path)
QMessageBox.information(self, ‘success’, ‘压缩成功!’)
else:
QMessageBox.critical(self, ‘error’, ‘压缩失败’)
else:
self.select_folder()
extract_path = QFileDialog.getExistingDirectory(window, “选择文件夹”, options=QFileDialog.ShowDirsOnly)
if bool(extract_path):
self.compress_to_zip(self.file_path, extract_path)
QMessageBox.critical(self, ‘success’, ‘压缩成功!’)
else:
QMessageBox.critical(self, ‘error’, ‘压缩失败’)

def select_file(self): # 选择文件
file_dialog = QFileDialog()
file_path, _ = file_dialog.getOpenFileName(self, “选择文件”, “”, “All Files (*)”)
if file_path:
self.file_path = file_path

def select_folder(self):
file_path, _ = QFileDialog.getExistingDirectory(window, “选择文件夹”, options=QFileDialog.ShowDirsOnly)
if file_path:
self.file_path = file_path

def compress_to_zip(self, file_path, zip_path):
with zipfile.ZipFile(zip_path, ‘w’) as zipf:
zipf.write(file_path, arcname=‘compressed_file.txt’)

合并表格

noinspection PyMethodMayBeStatic

class SelectDirectory(Layout):

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img



既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Python开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新

如果你觉得这些内容对你有帮助,可以添加V获取:vip1024c (备注Python)
img

如果你也是看准了Python,想自学Python,在这里为大家准备了丰厚的免费学习大礼包,带大家一起学习,给大家剖析Python兼职、就业行情前景的这些事儿。

一、Python所有方向的学习路线

Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。

二、学习软件

工欲善其必先利其器。学习Python常用的开发软件都在这里了,给大家节省了很多时间。

三、全套PDF电子书

书籍的好处就在于权威和体系健全,刚开始学习的时候你可以只看视频或者听某个人讲课,但等你学完之后,你觉得你掌握了,这时候建议还是得去看一下书籍,看权威技术书籍也是每个程序员必经之路。

四、入门学习视频

我们在看视频学习的时候,不能光动眼动脑不动手,比较科学的学习方法是在理解之后运用它们,这时候练手项目就很适合了。

四、实战案例

光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。

五、面试资料

我们学习Python必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

成为一个Python程序员专家或许需要花费数年时间,但是打下坚实的基础只要几周就可以,如果你按照我提供的学习路线以及资料有意识地去实践,你就有很大可能成功!
最后祝你好运!!!

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
img

高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

成为一个Python程序员专家或许需要花费数年时间,但是打下坚实的基础只要几周就可以,如果你按照我提供的学习路线以及资料有意识地去实践,你就有很大可能成功!
最后祝你好运!!!

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[外链图片转存中…(img-CYLhUMKH-1712781967002)]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值