随笔分类 - python自动化开发
摘要:在CentOS 7上使用Python 3和虚拟环境,请按照以下步骤操作: 首先,确保您的系统已安装Python 3。您可以使用以下命令检查Python 3是否已安装: python3 --version 如果Python 3已安装,您将看到类似于以下内容的输出: Python 3.x.x 如果未安装
阅读全文
摘要:要在Python中解压一个包含中文文件名的ZIP文件到指定的目录,你可以指定解压文件时所需的字符编码。下面是一个示例代码: import zipfile import os zip_file_path = '/path/to/your/chinese_file.zip' extract_dir =
阅读全文
摘要:首席引入依赖安装waitrss pip intsll waitress 然后在flask程序内引入依赖 使用server()函数代替app.run()函数 启动时,直接python xxx.py即可 from waitress import serve from flask import Flask
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:1、复制C:\Users\user\AppData\Local\Programs\Python\Python311目录下所有文件 2、在源电脑powershell运行pip freeze > D:\pycharm\requirements.txt 3、用第一步的文件覆盖目标电脑C:\Users\us
阅读全文
摘要:环境: 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
阅读全文
摘要:#!/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
阅读全文
摘要:使用命令:os.system(‘python file_name.py’) 解释:os.system是执行当前的系统命令 1、拿windows系统举例: # 由于ipconfig/all在windows中是查看ip地址 # 所以将此命令运行在os.system中,即可查看系统的ip地址等信息 imp
阅读全文
摘要: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
阅读全文
摘要:保留原顺序。 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] 用字
阅读全文
摘要:https://pypi.org/project/emoji/ pip install emoji 复制 字符串中间有 emoji 表情,替换掉。 text = "🐰贝贝有点甜🐰" res = emoji.demojize(text) # ':rabbit_face:贝贝有点甜:rabbit_f
阅读全文
摘要:在 Python 中,可以使用 str.replace() 方法来替换字符串中的指定字符。例如,如果要将字符串 "Hello World!" 中的所有 "o" 替换为 "0",可以使用以下代码: ini 复制代码 >>> s = "Hello World!" >>> s = s.replace("o
阅读全文
摘要: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
阅读全文
摘要: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=
阅读全文
摘要:Linux下安装anaconda进入Anaconda的官网进行下载;将下载好的 Anaconda3-2020.11-Linux-x86_64.sh copy到Linux目录下,运行如下命令;bash Anaconda3-2020.11-Linux-x86_64.sh复制代码1.安装好后,需要配置环境
阅读全文
摘要:Python生成requirements.txt方法 requirements.txt可以通过pip命令自动生成和安装,这种情况更适用于此项目是单独的虚拟python环境,生成requirements.txt文件。 安装requirements.txt依赖:pip install -r requir
阅读全文
摘要:问题描述: 1、(先添加时间戳,再复制移动,两个文件加下面的文件名都被修改)将 /home/kangle/webdata/JPEGImages 路径下的111.jpg文件添加当前时刻的时间戳 重命名为类似2018-03-27-18-11-11_111.jpg的形式,而且保存到另外一个路径/home/
阅读全文
摘要:最近给运维写一个系统维护的python脚本,但是被告知生产环境有很多服务器没有安装python解释器,于是在网上搜索多pyinstaller解决方案,本文简单记录之。 下载pyinstaller。 最新的pyinstaller版本为2.0版本,官方网站http://www.pyinstaller.o
阅读全文
摘要:MySQL之load data和select into outfileselect into outfile 今天上午,帮助业务方解决了一个问题,过程大概是这样的。业务方有一个需求是要实现在客户端的应用服务器使用select into outfile的方法导出一个文件。这个需求之前也做过,就是简单的
阅读全文