Python的城市词典API包装器
udp的Python项目详细描述
城市词典
城市字典API的简单Python包装器。在
安装
使用PyPI:
pip install udpy
使用
城市定义
此模块定义UrbanDefinition,一个表示每个城市词典定义的对象。 UrbanDefinition具有以下可访问属性:
- word:正在定义的单词
- definition:单词的定义
- example:用法示例
- upvotes:城市词典上的赞成票数
- downcots:城市词典上的否决票数
示例
创建客户端:
^{pr2}$按单词查找:
defs=client.get_definition('netflix and chill')>[ListofUrbanDefobjects]
查找随机单词:
rand=client.get_random_definition()>[ListofUrbanDefobjects]
阅读定义:
fordindefs:print(d.definition)>Itmeansthatyouaregoingtogoover...>codefortwopeoplegoingtoeachothers...><otherNetflixandChilldefinitions>...
UrbanDefinition字符串表示:
fordindefs:print(d)>NetflixandChill:Itmeansthatyouaregoingtogoovertoyourpar...(21776,7750)>netflixandchill:codefortwopeoplegoingtoeachothershousesan...(8056,2622)><word>:<definitiontrimmedto50characters>(<upvotes>,<downvotes>)
它还具有异步接口。只需使用AsyncUrbanClient
并添加awaits。在
- 项目
标签: