随笔分类 - 常用的自动化脚本
摘要:import pymysql,xlwt,os sql1='''SELECT type, count( * ) AS 激活数量, sum( IF ( severity = 1, 1, 0 ) ) AS 1级数量, sum( IF ( severity = 2, 1, 0 ) ) AS 2级数量, su
阅读全文
摘要:import pymysql,xlwtdef export_excel(table_name): host,user,passwd,db='192.168.1.10','root','zentao_123','zentao' coon=pymysql.connect(host=host,user=u
阅读全文
摘要:import pymysql,xlwt def export_excel(table_name): host,user,passwd,db='192.168.1.152','root','myjcyf','us_sys' coon=pymysql.connect(host=host,user=use
阅读全文
摘要:#第一步:调用pandas包 import pandas as pd #第二步:读取数据 iris = pd.read_excel(r'D:\pylx\20210622\12.xls')#读入数据文件 class_list = list(iris['所属部门'].drop_duplicates())
阅读全文
摘要:break用法:循环的时候,循环一次即停止 import pymysql,xlwt FI = pymysql.connect( host='*',user='root',passwd='*', port=*,db='z*',charset='utf8' #port必须写int类型, #charset
阅读全文
摘要:在python里,1个=号是赋值,==号是IF后面的等于
阅读全文
摘要:import os,time,shutil root=r'D:\pylx\20210622' while True: for item in os.listdir(root): abs_path = os.path.join(root, item) if time.time()-os.path.ge
阅读全文
摘要:sql = '''select case left(d.name,2) when 'DD' then '*' when 'DW' then '*' when 'ZN' then '*' when 'DL' then '*' WHEN 'HB' then '华北' when 'ZH' then'*'
阅读全文
摘要:import os,random,yaml def readyml(yamlPath):#定义一个读取yaml文件的函数 if not os.path.isfile(yamlPath): raise FileNotFoundError("文件路径不存在, 请检查路径是否正确: %s" % yamlP
阅读全文
摘要:https://blog.csdn.net/Nire_Yeyu/article/details/104683888/ 安装:pip install pyinstaller 安装时报错,原因是环境变量需要在多配一个路径 打包为exe,版本尽量选择python3.6+32位版本,因为win64位系统向下
阅读全文
摘要:import random,string res_lit=[] for i in range(100): rand_num = str(random.randint(0, 9999)) rand_num=rand_num.zfill(4) username="zr"+rand_num passwor
阅读全文
摘要:import os,datetime,shutil path=r'D:\pylx\20210622' files=os.listdir(path) today=datetime.datetime.now() dqr=today.strftime('%Y%m%d') for i,f in enumer
阅读全文
摘要:touch test_{1..300}.txt #!/bin/sh source /etc/profile path="/a/zl/tmp" if [ ! -d path ]; then mkdir -p $path fi for index in {0..1000} do num=`expr $i
阅读全文
摘要:import os,randompath=r"D:\pylx\20210622"for i in range(20): ym = '202106' d = random.randint(10, 22) dd = str(d) rand_num = str(random.randint(0, 9999
阅读全文
摘要:import os path=r"D:\pylx\20210622" for i in range(20): a="202106180030253{}.file".format(i) file_name = path + "\\" + a isExists=os.path.exists(file_n
阅读全文
浙公网安备 33010602011771号