随笔分类 - python script
common functional tool
摘要:1. get import requests # 最简单的get请求 r = requests.get(url) print(r.status_code) print(r.json()) # url 中?key=value&key=value r = requests.get(url, params
阅读全文
摘要:1. 通过使用md5字符串比较2个文件 python3
阅读全文
摘要:python gevent使用例子 from gevent.pool import Pool POOL_SIZE = 100 def process(func, param1_list, param2_list) stat = {} pool = Pool(POOL_SIZE) results =
阅读全文
摘要:#!/usr/bin/python # -*- coding: utf-8 -*- """ Created on Tue Aug 8 17:01:54 2017 @author: http://www.pythoner.com/357.html 也许你希望在终端上输出一些带有颜色或者粗体、下划线等样式的信息,就像man中的那样,那么这篇文章将会起到些许作用。 在Linux终端中,使用转义...
阅读全文
摘要:python 中 time 有三种格式: float, struct tuple(time.struct_time 或 datetime.datetime), str 常用的: float --> struct tuple: time.localtime( float ) struct time t
阅读全文
摘要:使用命令行(ssh)对Gerrit进行查询, 官方地址:https://review.openstack.org/Documentation/cmd-query.html程序例子import os, jsondef get_patch_info(GERRIT_HOME, patch_id): ...
阅读全文
摘要:下载地址:http://www.crummy.com/software/BeautifulSoup/bs4/download/4.3/beautifulsoup4-4.3.2.tar.gz 说明:这个版本使用python 2.7比较好。 install: 解压缩,然后运行python setup.p
阅读全文
摘要:使用basic auth 的3种方式 1. 设置header 2. 使用 HTTPBasicAuthHandler, 并install。执行认证一次,可以多次访问 3. 含有身份验证的网页,无论是 http 还是 https, 以下代码均适用。(如果还是报权限问题,有可能是 header 问题。)
阅读全文
摘要:装饰器函数:def function_wrapper(wrapped): def _wrapper(*args, **kwargs): return wrapped(*args, **kwargs)return _wrapper@function_wrapperdef funct...
阅读全文
摘要:1. 连接FTP serverimport ftplibftp = ftplib.FTP(ftpserver, user, passwd)等同于import ftplibftp = ftplib.FTP()ftp.connect(ftpserver)ftp.login(user,passwd) 对...
阅读全文
摘要:继电器常识: 继电器有三个接线柱:常开(NO),常闭(NC),接地(C) 如果连接的时间长,偶尔需要断电, 那么接NC 和 C, 这样继电器set on 时为断电。除此之外,继电器还可以控制按键,以及长按。 继电器接通时,该继电器的灯会亮。ZZR08有8个继电器,以一个字节表示其整体状态...
阅读全文
摘要:def score(dices_input): count = {}.fromkeys(range(1, 7), 0) points = 0 for dice_side in dices_input: count[dice_side] += 1 # print ...
阅读全文
摘要:#!/bin/python#import platformdef TestPlatform(): print ("----------Operation System--------------------------") #Windows will be : (32bit, Windo...
阅读全文
摘要:= 15(unmatched!);adb OK; Crashlogs: 0; Tombstones: 1; Sigs: 2+2+0+0; Throttlings: 0+0+0+0; Device errors: 0" addedBy="muxiaofx@muxiaofx-desk{clie...
阅读全文
摘要:see: http://www.cnblogs.com/sunada2005/p/3193300.html 一、可使用的第三方库 python中处理excel表格,常用的库有xlrd(读excel)表、xlwt(写excel)表、openpyxl(可读写excel表)等。xlrd读数据较大的exce
阅读全文
摘要:import argparse'''The following code is a Python program that takes a list of integers and produces either the sum or the max''' '''usage: argparse...
阅读全文
摘要:'''Created on Feb 7, 2013@author: changxue@summary: personal utils'''import os, time, shutil#current_time = time.strftime('%Y-%m-%d_%H%M', time.localtime(time.time()))current_time = time.strftime('%Y-%m-%d', time.localtime(time.time()))logfile = os.path.join(&
阅读全文
摘要:'''Created on Feb 22, 2013@author: changxue@summary: aim: generate jar file path: 1. copy original jar to target dir 2. java t...
阅读全文
摘要:'''Created on Feb 22, 2013@author: changxue@summary: extract all archive files in src_dir into target_dir'''import os, shutil_list_postfix = ['.rar', '.zip', '.jar']tool_path = os.path.join(r'C:\Program Files\7-Zip')from common_util import _cre
阅读全文

浙公网安备 33010602011771号