蟒蛇的笑话
axju-jokes的Python项目详细描述
Python的笑话。
我真的很难过,没有叫笑话的包裹。所以我决定创造一个,真的 快。这个包有一些函数,可以返回一些笑话、引语或事实。 如果你难过,就用笑话包吧。:)
安装
pip install axju-jokes
命令行
您可以从命令行退出该函数。有两个入口点:
$ joke $ python -m joke
如果没有争论,它将返回一个随机的笑话,引用或事实。你可以设定一个 尤其是API。例如,一些CAT事实:
$ joke cat
使用“帮助”查看可能的API:
$ joke --help
示例
一些笑话示例
fromjoke.jokesimport*# This will import all joke-functions (geek, icanhazdad, chucknorris, icndb)# Now you can use them to get some jokes.# For example you can display 10 Chuck Norris jokes.foriinrange(10):print(chucknorris())# Or get a random joke-function.fromrandomimportchoiceprint(choice([geek,icanhazdad,chucknorris,icndb])())
一些引用示例
fromjoke.quotesimport*# get a quote from quotesondesign.comprint(quotesondesign())# you can get more then one with one requestforquoteinquotesondesign(5):print(quote)# and you can get the datadata=quotesondesign(format='data')print(data['quote'])print(data['author'])# get quote from stormconsultancy.co.ukprint(stormconsultancy())# You can set the ID to get a specific quoteprint(stormconsultancy(id=2))# the stormconsultancy-function give you also the datadata=stormconsultancy(id=2,format='data')print(data['quote'])print(data['author'])
同时检查示例文件夹。
进口复活节彩蛋
>>> import joke.eggs Chuck Norris has to register every part of his body as a separate lethal weapon. His spleen is considered a concealed weapon in over 50 states.
API的
为了搞笑,我用了一些开放的api。如果你知道一些缺失的api,请 联系我。到目前为止,使用的api如下。
开发
克隆回购:
git clone https://github.com/axju/joke.git
创建虚拟环境并更新开发工具:
python3 -m venv venv source venv/bin/activate pip install --upgrade wheel pip setuptools twine tox
安装本地:
pip install -e .
运行一些测试:
tox python -m unittest discover python setup.py test
发布软件包:
python setup.py sdist bdist_wheel twine upload dist/*