自动从文件匹配数值并计算总和

该脚本自动从文档中匹配两个字符串之间的数字,并计算其总和。 import re numlist = total = 0 f = open "a.txt", encoding='utf8' line = f.readline while line: result = re.findall ". successNum . failedNum. ", line if result

python获取一年中所有的节假日

import arrow import datetime from chinese calendar import is workday def isLeapYear years : if years % 4 == 0 and years % 100 = 0 or years % 400 == 0 : days sum = 366 return days sum else: days

elasticsearch允许远程访问

vi /etc/elasticsearch/elasticsearch.yml 取消注释并修改如下: network.host: 0.0.0.0 cluster.initial master nodes: "node 1", "node 2" 重启elasticsearch: systemctl restart elasticsearch

统计服务器新增文件及其路径、大小

推荐python3运行该脚本,作用就是统计服务器新增文件及其路径、大小。 import time import datetime import os dirname = localtime = time.mktime time.strptime datetime.datetime.now .strftime "%Y %m %d" , "%Y %m %d" aftertime

python自动下载网站图片

from urllib import request from lxml import etree import time for pagenum in range 330,400 : 伪造头信息 headers = { "User Agent":"Mozilla/5.0 Windows NT 10.0; Win64; x64 AppleWebKit/537.36 KHTML, like