Skip to content

Instantly share code, notes, and snippets.

import argparse
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
const=sum, default=max,
help='sum the integers (default: find the max)')
args = parser.parse_args()
@lixinsu
lixinsu / prettytable.py
Created March 23, 2018 08:37
pretty table usage
from prettytable import PrettyTable
table = PrettyTable(["animal", "ferocity"])
table.add_row(["wolverine", 100])
@lixinsu
lixinsu / vim1.txt
Created March 23, 2018 06:53
vim显示彩色字 show color text
download from ===> https://vim.sourceforge.io/scripts/download_script.php?src_id=14498
install details
vim AnsiEsc.vba.gz
:so %
:q
Usage: edit a file containing escape sequences, then type :AnsiEsc
color setting:
@lixinsu
lixinsu / log.txt
Last active May 27, 2018 04:36
python log usage
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
fmt = logging.Formatter('%(asctime)s: [ %(message)s ]','%m/%d/%Y %I:%M:%S %p')
console = logging.StreamHandler()
console.setFormatter(fmt)
logger.addHandler(console)
log_file = 'tmp.log'
if log_file: