整理多位测开大佬累计多年的私人笔记。隆重公布
python数据类型转化
配置文件相关:
import configparser
cfp = configparser.ConfigParser()
cfp.read("test.ini")
'''获取所有的selections'''
selections = cfp.sections()
print(selections) # ['Title1', 'Title2']
'''获取指定selections下的所有options'''
options = cfp.options("Title1")
print(options) # ['key1', 'key2']
'''获取指定selection下的指定option的值'''
value= cfp.get("Title1", "key1")
print(value) # 1111111111
'''判断是否含有指定selection 或 option'''
print(cfp.has_section("Title1")) # True
print(cfp.has_option("Title1", "key3")) # False
import configparser
cfp = configparser.ConfigParser()
cfp.read("test.ini")
cfp.add_section("Title3") # 设置option的值
cfp.set("Title3", "key1", "1111111111") # 注意这里的selection一定要先存在!
cfp.set("Title3", "key2", "2222222222")
cfp.remove_section("Title3") # 移除指定selection
cfp.remove_option("Title2", "key1") # 移除指定selection下的option
with open("test.ini", "w+") as f:
cfp.write(f)
django相关:
sqlite3 xxx
.tables
select * from 表;
update 表 set xx=xx where xx=xx
服务器拉代码部署django
git fetch --all
git reset --hard origin/master
find . | xargs grep link-off 查找带任何字符串的文件
json.dumps(d, ensure_ascii=False, encoding='utf-8'))
cat ~/.gitconfig | head -10 查看git用户名等
ps -ef | grep Monitor | grep -v grep | awk '{print $2}' | xargs kill -9 按照进程名杀死进程
git push origin master:test -f
Django 查询filter 常见查询方法