python small tips

sort dict by value python

To get the values use

<span class="pln">sorted</span><span class="pun">(</span><span class="pln">data</span><span class="pun">.</span><span class="pln">values</span><span class="pun">())</span>

To get the matching keys, use a key function

<span class="pln">sorted</span><span class="pun">(</span><span class="pln">data</span><span class="pun">,</span><span class="pln"> key</span><span class="pun">=</span><span class="pln">data</span><span class="pun">.</span><span class="pln">get</span><span class="pun">)</span>

To get a list of tuples ordered by value

<span class="pln">sorted</span><span class="pun">(</span><span class="pln">data</span><span class="pun">.</span><span class="pln">items</span><span class="pun">(),</span><span class="pln"> key</span><span class="pun">=</span><span class="kwd">lambda</span><span class="pln"> x</span><span class="pun">:</span><span class="pln">x</span><span class="pun">[</span><span class="lit">1</span><span class="pun">])</span>
最近的文章

some interesting linux command

1. Supervise command (run every 2s) watch "ls -larth"2. Kill program using one port sudo fuser -k 8000/tcp3. Limit memory usage for following commands ulimit -Sv 1000 # 1000 KBs = 1 MBulimit -Sv unlimited # Remove limit4. Rename selected...…

command interesting command linux shell继续阅读
更早的文章

漏洞测试平台——SQLi-labs

SQLi-labs是个专门用来学习SQL注入的开源漏洞测试平台,基于php+mysql开发,所以里面涉及的SQL注入都是mysql语法。下载的地址是https://github.com/Audi-1/sqli-labs下载安装按照readme里面要求即可,这里不多废话。下面是每个题目的具体分析:1、error based string sqli首先是源码:$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";$result=mysql_qu...…

sqli sqli-labs sql注入继续阅读