随笔分类 -  python自动化开发

摘要:在CentOS 7上使用Python 3和虚拟环境,请按照以下步骤操作: 首先,确保您的系统已安装Python 3。您可以使用以下命令检查Python 3是否已安装: python3 --version 如果Python 3已安装,您将看到类似于以下内容的输出: Python 3.x.x 如果未安装 阅读全文
posted @ 2024-08-06 15:36 Oops!# 阅读(74) 评论(0) 推荐(0) 编辑
摘要:要在Python中解压一个包含中文文件名的ZIP文件到指定的目录,你可以指定解压文件时所需的字符编码。下面是一个示例代码: import zipfile import os zip_file_path = '/path/to/your/chinese_file.zip' extract_dir = 阅读全文
posted @ 2024-05-17 08:54 Oops!# 阅读(116) 评论(0) 推荐(0) 编辑
摘要:首席引入依赖安装waitrss pip intsll waitress 然后在flask程序内引入依赖 使用server()函数代替app.run()函数 启动时,直接python xxx.py即可 from waitress import serve from flask import Flask 阅读全文
posted @ 2024-04-10 16:12 Oops!# 阅读(701) 评论(0) 推荐(0) 编辑
摘要:Turns out that Flask sets request.data to an empty string if the content type of the request is application/x-www-form-urlencoded. Since I'm using a J 阅读全文
posted @ 2024-04-07 16:22 Oops!# 阅读(34) 评论(0) 推荐(0) 编辑
摘要:import pandas as pd """ 1. 将字典数据写入Excel key value 为值,列"""data = {'a': 1, 'b': 2, 'c': 3, 'd': 4} def save_to_excel(data): """ 将字典数据存入Excel """ pf = pd 阅读全文
posted @ 2024-03-27 14:21 Oops!# 阅读(579) 评论(0) 推荐(0) 编辑
摘要:1、复制C:\Users\user\AppData\Local\Programs\Python\Python311目录下所有文件 2、在源电脑powershell运行pip freeze > D:\pycharm\requirements.txt 3、用第一步的文件覆盖目标电脑C:\Users\us 阅读全文
posted @ 2023-12-19 13:31 Oops!# 阅读(575) 评论(0) 推荐(0) 编辑
摘要:环境: CentOS Linux release 7.9.2009 起因: Centos 7 自带Python2.7.5版本。而默认的 YUM 安装的python3是 3.6版本,遂升级到3.8版本。 install Python3.8 yum install -y centos-release-s 阅读全文
posted @ 2023-11-20 15:04 Oops!# 阅读(1899) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python import os import sys list=[] folder_path="/root" def search_files(folder_path): search_string = "测试" for root, dirs, files in os.wal 阅读全文
posted @ 2023-10-09 09:55 Oops!# 阅读(72) 评论(0) 推荐(0) 编辑
摘要:使用命令:os.system(‘python file_name.py’) 解释:os.system是执行当前的系统命令 1、拿windows系统举例: # 由于ipconfig/all在windows中是查看ip地址 # 所以将此命令运行在os.system中,即可查看系统的ip地址等信息 imp 阅读全文
posted @ 2023-08-04 16:08 Oops!# 阅读(152) 评论(0) 推荐(0) 编辑
摘要:3 You can use pandas.ExcelFile to have a peek at the sheet names, then select the sheets to keep with any method (here your regex), finally load with  阅读全文
posted @ 2023-08-04 11:06 Oops!# 阅读(29) 评论(0) 推荐(0) 编辑
摘要:保留原顺序。 old_list = [2, 3, 4, 5, 1, 2, 3] new_list = [] for i in old_list: if i not in new_list: new_list.append(i) print(new_list) # [2, 3, 4, 5, 1] 用字 阅读全文
posted @ 2023-05-24 09:35 Oops!# 阅读(26) 评论(0) 推荐(0) 编辑
摘要:https://pypi.org/project/emoji/ pip install emoji 复制 字符串中间有 emoji 表情,替换掉。 text = "🐰贝贝有点甜🐰" res = emoji.demojize(text) # ':rabbit_face:贝贝有点甜:rabbit_f 阅读全文
posted @ 2023-05-24 09:33 Oops!# 阅读(574) 评论(0) 推荐(0) 编辑
摘要:在 Python 中,可以使用 str.replace() 方法来替换字符串中的指定字符。例如,如果要将字符串 "Hello World!" 中的所有 "o" 替换为 "0",可以使用以下代码: ini 复制代码 >>> s = "Hello World!" >>> s = s.replace("o 阅读全文
posted @ 2023-05-24 08:39 Oops!# 阅读(1028) 评论(0) 推荐(0) 编辑
摘要:import pandas as pd import csv f = open(r'C:/Users/will/Desktop/log-2023-05-22.log',encoding='utf-8') data = pd.read_csv(f,sep='\n',header=None) for i 阅读全文
posted @ 2023-05-22 18:11 Oops!# 阅读(32) 评论(0) 推荐(0) 编辑
摘要:import pandas as pd import csv file = 'd:/raw_data.txt' new_file="d:/new_data.csv" data = pd.read_csv(file,delimiter=',',quoting=csv.QUOTE_NONE,names= 阅读全文
posted @ 2023-05-22 09:31 Oops!# 阅读(128) 评论(0) 推荐(0) 编辑
摘要:Linux下安装anaconda进入Anaconda的官网进行下载;将下载好的 Anaconda3-2020.11-Linux-x86_64.sh copy到Linux目录下,运行如下命令;bash Anaconda3-2020.11-Linux-x86_64.sh复制代码1.安装好后,需要配置环境 阅读全文
posted @ 2023-04-26 17:00 Oops!# 阅读(538) 评论(0) 推荐(0) 编辑
摘要:Python生成requirements.txt方法 requirements.txt可以通过pip命令自动生成和安装,这种情况更适用于此项目是单独的虚拟python环境,生成requirements.txt文件。 安装requirements.txt依赖:pip install -r requir 阅读全文
posted @ 2023-04-23 14:02 Oops!# 阅读(73) 评论(0) 推荐(0) 编辑
摘要:问题描述: 1、(先添加时间戳,再复制移动,两个文件加下面的文件名都被修改)将 /home/kangle/webdata/JPEGImages 路径下的111.jpg文件添加当前时刻的时间戳 重命名为类似2018-03-27-18-11-11_111.jpg的形式,而且保存到另外一个路径/home/ 阅读全文
posted @ 2023-04-14 22:41 Oops!# 阅读(219) 评论(0) 推荐(0) 编辑
摘要:最近给运维写一个系统维护的python脚本,但是被告知生产环境有很多服务器没有安装python解释器,于是在网上搜索多pyinstaller解决方案,本文简单记录之。 下载pyinstaller。 最新的pyinstaller版本为2.0版本,官方网站http://www.pyinstaller.o 阅读全文
posted @ 2023-04-12 14:49 Oops!# 阅读(544) 评论(0) 推荐(0) 编辑
摘要:MySQL之load data和select into outfileselect into outfile 今天上午,帮助业务方解决了一个问题,过程大概是这样的。业务方有一个需求是要实现在客户端的应用服务器使用select into outfile的方法导出一个文件。这个需求之前也做过,就是简单的 阅读全文
posted @ 2023-04-10 09:57 Oops!# 阅读(196) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示