Skip to content

Instantly share code, notes, and snippets.

View MOOOWOOO's full-sized avatar

Jux Liu MOOOWOOO

  • Chongqing, China
View GitHub Profile
@MOOOWOOO
MOOOWOOO / tieba.py
Last active January 16, 2019 01:49
auto sign on baidu tieba
# -*- coding:utf-8 -*-
import requests
import re
__author__ = 'Jux.Liu'
# 修改自己的cooki
cookie = ''
# 构建请求头数据
@MOOOWOOO
MOOOWOOO / dir_tree.py
Created September 19, 2016 03:58
print tree of dir
import os
def Test3(rootDir, level=1):
if level==1:
print(rootDir)
for lists in os.listdir(rootDir):
path = os.path.join(rootDir, lists)
print('│ ' * (level - 1) + '│--' + lists)
if os.path.isdir(path):
Test3(path, level+1)
@MOOOWOOO
MOOOWOOO / flex.css
Created August 11, 2016 04:59
flex
.one-box {
display : flex;
justify-content : center;
align-items : center;
}
.two-one-box {
display : flex;
flex-direction : column;
justify-content : space-between;
@MOOOWOOO
MOOOWOOO / py-gitignore
Last active May 2, 2024 19:03
python pycharm gitignore
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
@MOOOWOOO
MOOOWOOO / ArgumentParserInit.py
Last active April 10, 2017 08:26
new project use argument parser init
#!/usr/bin/env python
# coding: utf-8
import sys
from argparse import ArgumentParser
def main(*args):
pass

格式字符串手册

数字格式化

下面的表格展示了使用Python的后起新秀str.format()格式化数字的多种方法,包含浮点数格式化与整数格式化示例。可使用 print("FORMAT".format(NUMBER)); 来运行示例,因此你可以运行: print("{:.2f}".format(3.1415926)); 来得到第一个示例的输出。

数字      	格式    	输出  	    描述
3.1415926 	{:.2f} 	  3.14  	    保留小数点后两位
3.1415926 {:+.2f} +3.14 带符号保留小数点后两位
@MOOOWOOO
MOOOWOOO / ubuntu-terminal-maximize
Created July 18, 2016 02:31
ubuntu-terminal-maximize
sudo vim /usr/share/applications/gnome-terminal.desktop
Exec=gnome-terminal --maximize
@MOOOWOOO
MOOOWOOO / decode('string-escape')
Created July 14, 2016 03:24
decode('string-escape')
decode('string-escape')
@MOOOWOOO
MOOOWOOO / .zshrc
Last active May 6, 2023 15:02
Init a virtual machine
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
setopt no_nomatch
export TERM="xterm-256color"
ZSH_TIME='24'
eval "$(thefuck --alias fuck)"
@MOOOWOOO
MOOOWOOO / count-timezone.js
Last active December 2, 2016 01:59
date function list of js.
function calcTime(city, offset) {
let d = new Date();
let utc = d.getTime() + (d.getTimezoneOffset() * 60000);
let nd = new Date(utc + (3600000 * offset));
let gmtTime = new Date(utc);
let day = nd.getDate();
let month = nd.getMonth();
let year = nd.getYear();
let hr = nd.getHours(); //+ offset
let min = nd.getMinutes();