午餐机器人API的Python接口。
lunchbot-python的Python项目详细描述
午餐Python
一个Python包,用于与@Nero2k午餐机器人API交互,后者是一个提供Eatery Kista Nod餐厅每周午餐菜单的API。在
这个包将菜单属性完全解析为Python对象,非常容易使用。在
安装
安装通过以下方式完成:
pip install lunchbot-python
快速启动
有关更多代码示例的详细指南,请参阅official documentation。在
下面还有一个图像快速启动示例和一个简洁的代码示例,但也可以在上面链接的官方文档中找到。在
"""Websocket/API exampleThis example shows you the "standard" way of getting the weekmenu, which will return a parsed list of Day objects. The Day class is implemented with this APINOTE: Want to do this with less code?Check the compact example."""fromeatery_nodimportEateryNod#Import the librarymenu=EateryNod.Menu()#Create a menu objectmenu.initialize()#Initialize (this is only required when using WebSockets)print("Retrieving menu...")#Print out the statusweek_menu=menu.get_menu()#Get the menufordayinweek_menu:#Loop through all the days in the menumenu_items_str="\n".join(day.menu_items)#Format the menu items to a pretty string as they are returned as a listprint(day.day_name_sv)#Print out the day name (in Swedish)print(menu_items_str)#Print out the menu itemsprint("Day information:")#Print out a nice dividerprint("Date: "+str(day.day_date))#Print out the day dateprint("Dessert served?: "+str(day.dessert_served))#Print out if dessert is served (this will print either True or False)print("Pancakes served?: "+str(day.pancakes_served))#Print out if pancakes are served (this will print either True or False)print("Hamburgers served?: "+str(day.burgers_served))#Print out if hamburgers are served (this will print either True or False)print("---------------------------------------------------")#Print out a divider linelast_retrieved=menu.last_retrieved["json"]#Get when the menu was last retrievedprint("Menu retrieved: "+str(last_retrieved))#Print out when the menu was last retrieved.
变更日志
请参阅“Releases”选项卡和文档。在
更多文档
代码的所有函数、变量和属性都有文档记录。您可以在正式的库文档中找到它,该文档由GitBook提供,托管在https://lunchbot-python.albins.website。在
(尚未上载任何代码,只是已创建的初始存储库)
- 项目
标签: