正文
'*/*'
,
'Accept-Encoding'
:
'gzip, deflate'
,
'Connection'
:
'close'
,
'Content-Length'
:
'16'
,
'Content-Type'
:
'application/json'
,
'Host'
:
'httpbin.org'
,
'User-Agent'
:
'python-requests/2.4.3 CPython/3.4.0'
,
'X-Request-Id'
:
'xx-xx-xx'
},
'json'
:
{
'key'
:
'value'
},
'origin'
:
'x.x.x.x'
,
'url'
:
'http://httpbin.org/post'
}
看起来还不错对不对。
比如我想搜 Python 里面怎么把 timestamp 转 datetime,输入这样的命令:
howdoi python timestamp to datetime
返回结果就是这样:
from datetime import datetime
ts = int("1284101485")
# if you encounter a "year is out of range" error the timestamp
# may be in milliseconds, try `ts /= 1000` in that case
print(datetime.utcfromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))
那 Java 它会吗?试试看:
howdoi java timestamp to datetime
返回结果就是这样:
Timestamp stamp = new Timestamp(System.currentTimeMillis());
Date date = new Date(stamp.getTime());
System.out.println(date);
有点牛逼啊,搜啥答案都有,准确率还蛮高。
以上是怎么实现的?没错,就是借助于 howdoi 这个项目。
howdoi
那么这个 howdoi 究竟是个什么?我们 GitHub 上就能找到,链接地址为:https://github.com/gleitz/howdoi。
看下简介:
Are you a hack programmer? Do you find yourself constantly Googling for how to do basic programming tasks?
Suppose you want to know how to format a date in bash. Why open your browser and read through blogs (risking major distraction) when you can simply stay in the console and ask howdoi.
意思就是说,如果你想搜一些编程相关的解决方案,我们可以不用再去开浏览器,然后再去读文档或者博客,你可以通过 howdoi 就能直接得到答案。
操作就是上面我们讲的。
howdoi 是一个 Python 项目,我们可以 pip 命令安装:
如果是 Mac 的话,推荐使用 brew 来安装:
安装完了就能使用 howdoi 命令了。
完整用法如下: