[python]justping——找出响应时间最短的 ip/域名

介绍

通过解析 ping 命令执行结果,找出 ping 值最小的 ip/域名

项目主页:

https://github.com/mozillazg/justping

用法

justping.py [filename] [+] [ip/host…]

参数

filename —— 内容为一行一个 ip/域名的文件
+ —————- 同时比较文件内及后面输入的 ip/域名
ip/host ——– ip/域名

示例

  • >python justping.py
    ######################################################
                             host(ip)   time    lost
          baidu.com(123.125.114.144):  170ms    0%
               qq.com(119.147.15.13):   66ms    0%
    ######################################################
    qq.com has the min ping time: 66 ms
    >
    
  • >python justping.py baidu.com 8.8.8.8
    ######################################################
                             host(ip)   time    lost
          baidu.com(123.125.114.144):  170ms    0%
                    8.8.8.8(8.8.8.8):  124ms    0%
    ######################################################
    8.8.8.8 has the min ping time: 124 ms
    >
    
  • >python justping.py hosts.txt
    ######################################################
                            host(ip)   time    lost
           baidu.com(220.181.111.86):   81ms    0%
               qq.com(119.147.15.13):   63ms    0%
    ######################################################
    qq.com has the min ping time: 63 ms
    >
    
  • >python justping.py hosts.txt + 8.8.8.8
    ######################################################
                            host(ip)   time    lost
           baidu.com(220.181.111.86):   81ms    0%
               qq.com(119.147.15.13):   63ms    0%
                    8.8.8.8(8.8.8.8):  124ms    0%
    ######################################################
    qq.com has the min ping time: 63 ms
    >
    

[python]简单获取图片 MIME 类型及解码字符串

获取图片 MIME 类型

https://github.com/mozillazg/image-mime

使用

>>> with open('test', 'rb') as f:
...     print get_image_mime(f.read())
...
image/png
>>>
>>> with open('test.exe', 'rb') as f:
...     print get_image_mime(f.read())
...
application/octet-stream

转换未知编码的字符串为 Unicode 字符串

https://gist.github.com/3870483

使用

>>> decode_('\xc4\xe3')
u'\u4f60'
>>> decode_('\xe4\xbd\xa0')
u'\u4f60'
>>>

让 PayPal 使用信用卡美元账户支付订单

默认情况下,PayPal 使用信用卡人民币账户支付外币订单。

人民币支付01

当日汇率

下面是改用美元支付的步骤:

进入用户信息
用户信息

进入[财务信息]-更改币种
财务信息-币种

添加美元为首选币种
管理币种-添加美元为首选

返回到[财务信息] 进入[我的预核准付款]-更新
财务信息-我的预核准付款-更新

选择[设置可用资金来源]
我的预核准付款-设置可用资金来源

管理资金来源-[兑换选项]
管理资金来源-兑换选项

修改[兑换选项]为“在给我的账单中使用卖家列出的币种”
修改兑换选项为-在给我的账单中使用卖家列出的币种

修改后:

美元支付