开发小技巧

1. pritty print xml

BeautifulSoup

from bs4 import BeautifulSoup

xml = '<group> <id>base</id> <name>Base</name> <default>false</default> <uservisible>false</uservisible> <packagelist> <packagereq requires="ruby" type="conditional">rubygem-abrt</packagereq> </packagelist> </group>'

 print(BeautifulSoup(xml, "xml").prettify())
 
XML='<group> <id>base</id> <name>Base</name> <default>false</default> <uservisible>false</uservisible> <packagelist> <packagereq requires="ruby" type="conditional">rubygem-abrt</packagereq> </packagelist> </group>'

python -c "from bs4 import BeautifulSoup; print(BeautifulSoup('$XML', \"xml\").prettify())"

 

2. python

d = {'a':1, 'b':2, 'c':{'a':1}}
import json
print(json.dumps(d, indent=4))

 

3. python 进程总结

 

4. Install python wheel file without using pip

python pip-10.0.1-py2.py3-none-any.whl/pip install --no-index setuptools-39.0.1-py2.py3-none-any.whl

5. dowload python with dependence

pip install --save-download pkgs pyramid

 6. curl 获取 定向 url

Get URL's redirect target with curl

 

posted @ 2018-07-30 00:14  lvmxh  阅读(137)  评论(0编辑  收藏  举报