如何制作营养膳食计算器_如何通过构建自动膳食计划器节省时间和金钱
如何制作營養(yǎng)膳食計算器
使用Google Calendar和Google Sheets API在正確的日子選擇正確的食譜。 (Use the Google Calendar and Google Sheets APIs to select the right recipe on the right day.)
Do you also get stressed out when you get the question “what’s for dinner tonight?” You’re not alone. I guess it’s the most asked question as the clock strikes 4 p.m. Deciding what to eat can be a tedious chore. Especially when you have small children with various after-school activities.
當您收到“今晚晚餐時間是什么”這個問題時,您還會感到壓力嗎? 你不是一個人。 我猜這是最常見的問題,因為時鐘是下午4點鐘。決定吃什么可能是一件繁瑣的工作。 特別是當您的孩子有各種各樣的課余活動時。
To avoid going to the supermarket every day, we usually write up a menu with recipes for the coming week. That way we can buy all our groceries in one supermarket visit. This saves us a lot of time. Besides that, it also saves us money. That is because we are less exposed to all the selling tricks supermarkets use.
為了避免每天去超市,我們通常會在下周寫一張包含食譜的菜單。 這樣,我們可以在一次超市訪問中購買所有雜貨。 這為我們節(jié)省了很多時間。 除此之外,它還為我們節(jié)省了金錢。 這是因為我們對超市使用的所有銷售技巧的了解較少。
Finding recipes for a whole week requires some thinking and planning. We have to take into account the eating preferences of all family members. Besides that, we have a limited time available for cooking each day. To make this easier, I built an automatic meal planner with these features:
尋找整整一周的食譜需要一些思考和計劃。 我們必須考慮所有家庭成員的飲食偏好。 除此之外,我們每天都有有限的時間做飯。 為了簡化此過程,我構(gòu)建了具有以下功能的自動膳食計劃器:
- extract the work planning for me and my wife from our shared Google calendars 從我們共享的Google日歷中提取我和我妻子的工作計劃
- extract our preferred recipes from a Google spreadsheet, 從Google電子表格中提取我們首選的食譜,
- repeat some recipes each week on the same day 每周在同一天重復(fù)一些食譜
- leave one week in between before repeating the other recipes 間隔一星期再重復(fù)其他食譜
- I like cooking more than my wife. So on days that I can’t cook the recipes should be short in time 我比老婆更喜歡做飯。 所以在我無法煮菜的日子里,食譜應(yīng)該很短
- upload the week menu in a Google calendar 將周菜單上傳到Google日歷中
Let’s jump right in.
讓我們跳進去。
使用Google日歷API和Google表格API (Using the Google calendar API and Google sheets API)
First, we’ll need to create a new Google Cloud project. Before we can use the Google calendar and sheets in this project, we need to enable the API’s. This is very well explained on the web pages below:
首先,我們需要創(chuàng)建一個新的Google Cloud項目 。 在此項目中使用Google日歷和工作表之前,我們需要啟用API。 以下網(wǎng)頁對此進行了很好的解釋:
Enabling the Google Calendar API
啟用Google Calendar API
Enabling the Google Sheets API
啟用Google Sheets API
When that’s done, we continue by importing the necessary Python packages.
完成后,我們將導(dǎo)入必要的Python包。
import config as cfg import pandas as pd import numpy as np from pathlib import Path from datetime import datetime from datetime import timedelta from googleapiclient.discovery import build from google.oauth2 import service_account組態(tài) (Configuration)
For privacy and security reasons, I keep some parameters in a separate config.py file. We import the file with the alias cfg. I will discuss these parameters further below with fictitious values. You can include them for your own app with values relevant to your case.
出于隱私和安全原因,我將一些參數(shù)保存在單獨的config.py文件中。 我們使用別名cfg導(dǎo)入文件。 我將在下面用虛擬值進一步討論這些參數(shù)。 您可以將它們包含在自己的應(yīng)用程序中,并提供與案例相關(guān)的值。
范圍 (Scopes)
With scopes, we define the access levels for the Google calendars and sheets. We will need read and write access to both the calendars and sheet. Thus we use the URLs below.
通過范圍,我們定義了Google日歷和工作表的訪問級別。 我們將需要同時訪問日歷和工作表 。 因此,我們使用下面的URL。
SCOPES = ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/spreadsheets']Google工作表ID和范圍 (Google sheet ID and range)
SPREADSHEET_ID = <Your Google sheet ID> RANGE = 'recepten!A:G'We need to specify the ID of the Google sheet with the recipes. Additionally, we specify the sheet range containing the recipes.
我們需要使用食譜指定Google工作表的ID。 此外,我們指定包含配方的圖紙范圍。
You can find the ID of your Google sheets by right-clicking on the sheet in Google Drive. Then select “Get shareable link”. You can find the ID after “https://drive.google.com/open?id=”.
您可以找到自己的Google表格的ID 右鍵單擊Google云端硬盤中的工作表。 然后選擇“獲取共享鏈接”。 您可以在“ https://drive.google.com/open?id=”之后找到ID。
In my Google sheet “recepten”, columns A to G contain information on each recipe. The screenshot below shows some sample content. So RANGE needs to be set to “recepten!A:G”.
在我的Google工作表“接收器”中,列A至G包含每個食譜的信息。 下面的屏幕快照顯示了一些示例內(nèi)容。 因此需要將RANGE設(shè)置為“ recepten!A:G” 。
Google日歷ID (Google Calendar IDs)
CALENDARID_1 = <Your Google Calendar ID> CALENDARID_2 = <Your partner's Google Calendar ID> CALENDARID_WEEKMENU = <Google Calendar ID for the week menu>We need to specify the Google Calendar IDs to get the events from. Make sure you have access to all calendars you want to include. You can find the ID by executing this script from the APIs Explorer.
我們需要指定Google日歷ID來獲取事件。 確保您有權(quán)訪問要包括的所有日歷。 您可以通過在API Explorer中執(zhí)行此腳本來找到ID。
For this project, we will extract the events of only two calendars. But you could adapt the code to loop over more calendars. I’ve also created a separate calendar to upload the recipes.
對于此項目,我們將僅提取兩個日歷的事件。 但是您可以修改代碼以遍歷更多日歷。 我還創(chuàng)建了一個單獨的日歷來上傳食譜。
活動標簽 (Event labels)
BUSY_EVENTS = [<Labels of busy calendar events>] FREE_EVENTS = [<Labels of free calendar events>] ALL_EVENTS = BUSY_EVENTS + FREE_EVENTSMy wife works in shifts and adds them to her Google Calendar by using letter codes. For example: “B” stands for the afternoon shift. This event is one of the BUSY_EVENTS.
我的妻子輪班工作,并使用字母代碼將其添加到她的Google日歷中。 例如:“ B”代表下午班次。 此事件是BUSY_EVENTS 。
When I have a day off, I add “HOLIDAY” to my calendar. This event is one of the FREE_EVENTS.
休息日后,將“ HOLIDAY”添加到日歷中。 此事件是FREE_EVENTS.
All the events are full-day events in the Google Calendars. You can use your own event labels scheme.
所有活動都是Google日歷中的全天活動。 您可以使用自己的事件標簽方案。
傳統(tǒng) (Traditions)
TRADITIONS = { 'Thursday' : 'fries'}With TRADITIONS, I mean that our family has a few days in the week on which we prepare a certain recipe. As we are from Belgium, this means eating fries once a week (for us on Thursday). And yes, before you’d ask, that is fries with mayonnaise.
使用TRADITIONS ,我的意思是我們一家人在一周中的幾天里會準備一些食譜。 因為我們來自比利時,所以這意味著每周要吃一次薯條(對我們來說是星期四)。 是的,在您問之前,那就是蛋黃醬。
You can specify your own traditions in a dictionary, with the name of the day as the key and the recipe as the value.
您可以在字典中指定自己的傳統(tǒng),以日期名稱為鍵,配方為值。
提前計劃的天數(shù) (Number of days to plan ahead)
Sometimes we can’t go to the supermarket on the day a new week menu is created. We might need some days to plan ahead. With NB_DAYS_BEFORE we give ourselves some slack. This means that the new week menu will be generated a certain number of days before the previous week menu has finished.
有時,我們在創(chuàng)建新周菜單的那天就不能去超市。 我們可能需要幾天的時間來計劃。 使用NB_DAYS_BEFORE我們可以放松一些。 這意味著新周菜單將在上周菜單完成之前的一定天數(shù)內(nèi)生成。
NB_DAYS_BEFORE = 3使用服務(wù)帳戶 (Using a service account)
We will use a service account to make use of the APIs in the project. The credentials.json file is the file that you can download when enabling the APIs.
我們將使用服務(wù)帳戶來利用項目中的API。 certificate.json文件是啟用API時可以下載的文件。
We create the credentials creds with the code below. These credentials enable authentication in the Google Calendars and Google sheet.
我們創(chuàng)建憑據(jù)creds與下面的代碼。 這些憑據(jù)可在Google日歷和Google工作表中啟用身份驗證。
creds = service_account.Credentials.from_service_account_file("credentials.json", scopes=cfg.SCOPES)獲取Google日歷活動 (Getting the Google Calendar events)
We start by creating the service object with the build method.
我們首先使用build方法創(chuàng)建服務(wù)對象。
service_cal = build('calendar', 'v3', credentials=creds)We are only interested in the events for the coming week. To filter these events, we specify the dates and format them with isoformat(). The parameters timeMin and timeMax need this format.
我們只對下一周的活動感興趣。 要過濾這些事件,我們指定日期并使用isoformat()對其進行格式化。 參數(shù)timeMin和timeMax需要這種格式。
def format_date(date):date_time = datetime.combine(date, datetime.min.time())date_time_utc = date_time.isoformat() + 'Z'return date_time_utcWith the method events().list of the service object, we extract the events. The extracted events are then filtered for the BUSY and FREE events. All other events on the Google Calendars are not relevant in this project. We keep the start and end date and the summary of the events.
通過服務(wù)對象的events()。list方法,我們可以提取事件。 然后,將提取的事件過濾為BUSY和FREE事件。 Google日歷上的所有其他事件與該項目無關(guān)。 我們保留事件的開始和結(jié)束日期以及摘要。
def get_event_date(event, timepoint):return event[timepoint].get('dateTime', event[timepoint].get('date'))def get_events_by_calendarId(service, calendarId, timeMin, timeMax, allEvents):events_result = service.events().list(calendarId=calendarId, timeMin=timeMin, timeMax=timeMax, singleEvents=True, orderBy='startTime').execute()events = events_result.get('items', []) events_list = [(get_event_date(e, 'start'), get_event_date(e, 'end'), e['summary'].upper()) for e in events if e['summary'].upper() in allEvents]return unfold_events_list(events_list)Some events spread over more than one day. For example, when you take holidays for more than one day. We unfold these multi-day events in daily events within the range of the coming week.
有些事件超過一天。 例如,當您休假超過一天時。 我們將在下一周的每日活動中展開這些多日活動。
def unfold_events_list(events_list):new_events_list = []for e in events_list:start = datetime.strptime(e[0], '%Y-%m-%d').date()end = datetime.strptime(e[1], '%Y-%m-%d').date()delta_days = (end - start).daysif delta_days > 1:for d in range(delta_days):unfolded_day = start + timedelta(days=d)if unfolded_day >= datetime.now().date() and unfolded_day <= datetime.now().date() + timedelta(days=6):new_events_list.append((unfolded_day, e[2]))else:new_events_list.append((start, e[2]))return new_events_listFinally, we want a Pandas DataFrame with the events of both calendars for the coming week. To get to that result, we convert the events lists to data frames and merge on the date. We also add the weekday to the merged data frame.
最后,我們需要一個帶有下兩個日歷事件的Pandas DataFrame。 為了獲得該結(jié)果,我們將事件列表轉(zhuǎn)換為數(shù)據(jù)框并在日期上合并。 我們還將工作日添加到合并的數(shù)據(jù)框中。
def create_events_df(events_list_1, events_list_2):events_df_1 = pd.DataFrame.from_records(events_list_1, columns=['date', 'events_cal_1'])events_df_2 = pd.DataFrame.from_records(events_list_2, columns=['date', 'events_cal_2'])events_df = events_df_1.merge(events_df_2, on='date', how='outer')events_df.date = pd.to_datetime(events_df.date)events_df.set_index('date', inplace=True)events_df.sort_index(inplace=True)dates = list(pd.period_range(START_DAY, NEXT_WEEK, freq='D').values)new_idx = []for d in dates:new_idx.append(np.datetime64(d))events_df = events_df.reindex(new_idx)events_df.reset_index(inplace=True)events_df['weekday'] = events_df.date.apply(lambda x: x.strftime('%A'))events_df.set_index('date', inplace=True)return events_dfTo make sure we cover all dates of the coming week, we use a period_range and reindex the merged data frame.
為確保涵蓋下一周的所有日期,我們使用period_range并為合并的數(shù)據(jù)框reindex period_range reindex 。
從Google工作表獲取食譜 (Getting the recipes from the Google sheet)
At this point, we have a data frame with all days of the coming week and the events (if any) occurring in the two calendars. Now we can start to extract the recipes from the Google sheet and assign a recipe to each day. As with the Google Calendar API, let’s start by creating the service object for the Google Sheets API.
至此,我們有了一個數(shù)據(jù)框架,其中包含下一周的所有日期,以及兩個日歷中發(fā)生的事件(如果有)。 現(xiàn)在,我們可以開始從Google工作表中提取食譜,并為每一天分配一個食譜。 與Google Calendar API一樣,讓我們??開始為Google Sheets API創(chuàng)建服務(wù)對象。
service_sheet = build('sheets', 'v4', credentials=creds)With the method spreadsheets().values().get we can extract the recipes from the Google Sheet.
使用電子表格sheets()。values()。get方法,我們可以從Google表格中提取配方。
def get_recipes(service, spreadsheetId, range):recipes_result = service.spreadsheets().values().get(spreadsheetId=spreadsheetId, range=range).execute()recipes = recipes_result.get('values', [])recipes_df = pd.DataFrame.from_records(recipes[1:], columns=recipes[0])recipes_df.last_date_on_menu = pd.to_datetime(recipes_df.last_date_on_menu, dayfirst=True)recipes_df.set_index('row_number', inplace=True)eligible_recipes = recipes_df[ (recipes_df.last_date_on_menu < PREV_WEEK) | (np.isnat(recipes_df.last_date_on_menu)) ]return recipes_df, eligible_recipesNext, we create a data frame with the recipes. I like working with Pandas DataFrames, but you could use other data structures as well of course.
接下來,我們使用配方創(chuàng)建一個數(shù)據(jù)框。 我喜歡使用Pandas DataFrames,但是您當然也可以使用其他數(shù)據(jù)結(jié)構(gòu)。
The row_number is a field calculated in the Google Sheet itself. We use the Google Sheet function ROW() for that. It will help to update the field last_date_on_menu in the correct row. We will update that date when a recipe is chosen for the coming week.
row_number是在Google表格本身中計算的字段。 我們?yōu)榇耸褂肎oogle Sheet函數(shù)ROW() 。 這將有助于在正確的行中更新字段last_date_on_menu 。 我們將在下周選擇食譜時更新該日期。
We need to make sure that a recipe is only repeated after one week. So we filter recipes_df by last_date_on_menu. This date must be empty or before the previous week.
我們需要確保一個星期后才重復(fù)一次食譜。 因此,我們篩選recipes_df通過last_date_on_menu 。 該日期必須為空或在前一周之前。
生成周菜單 (Generating the week menu)
In this step, we will assign an eligible recipe to each day of the coming week.
在此步驟中,我們將為下周的每一天分配合格的食譜。
def generate_weekmenu(service, events_df, traditions, free_events):weekmenu_df = events_df.copy()for i, r in events_df.iterrows():if r.weekday in traditions.keys():weekmenu_df.loc[i, 'recipe'] = traditions[r.weekday]weekmenu_df.loc[i, 'description'] = ''else:if r.weekday in ['Saturday', 'Sunday']:row_number = choose_recipe('difficult', i, weekmenu_df, eligible_recipes)update_sheet(service, row_number, i.strftime('%d-%m-%Y'), cfg.SPREADSHEET_ID)elif r.events_cal_1 in free_events or r.events_cal_2 in free_events \or pd.isnull(r.events_cal_1) or pd.isnull(r.events_cal_2):row_number = choose_recipe('medium', i, weekmenu_df, eligible_recipes)update_sheet(service, row_number, i.strftime('%d-%m-%Y'), cfg.SPREADSHEET_ID)else:row_number = choose_recipe('easy', i, weekmenu_df, eligible_recipes)update_sheet(service, row_number, i.strftime('%d-%m-%Y'), cfg.SPREADSHEET_ID)return weekmenu_dfTo take into account the work planning (BUSY and FREE events), we will use the difficulty of each recipe. A random recipe of the preferred difficulty will be added to weekmenu_df. Finally we drop it from the eligible recipes to avoid duplicate recipes in the same week.
考慮到工作計劃(忙碌和免費活動),我們將使用每種食譜的difficulty 。 首選難度的隨機配方將添加到weekmenu_df. 最后,我們將其從符合條件的食譜中刪除,以避免在同一周重復(fù)食譜。
def choose_recipe(difficulty, idx, weekmenu_df, eligible_recipes):choice_idx = np.random.choice(eligible_recipes.query("difficulty == '" + difficulty + "'" ).index.values)weekmenu_df.loc[idx, 'recipe'] = eligible_recipes.loc[choice_idx, 'recipe']weekmenu_df.loc[idx, 'description'] = eligible_recipes.loc[choice_idx, 'description']eligible_recipes.drop(choice_idx, inplace=True)return choice_idxThe method spreadsheets().values().update updates the Google Sheet.
方法電子表格().values()。update會更新Google表格。
def update_sheet(service, row_number, date, spreadsheetId):range = "recepten!F" + str(row_number)values = [[date]]body = {'values' : values}result = service.spreadsheets().values().update(spreadsheetId=spreadsheetId, range=range, valueInputOption='USER_ENTERED', body=body).execute()We iterate over each row of weekmenu_df. If the weekday is one of the TRADITIONS weekdays, we assign the corresponding recipe. For the other weekdays, we apply the following logic:
我們遍歷weekmenu_df每一行。 如果工作日是“傳統(tǒng)”工作日之一,則我們分配相應(yīng)的食譜。 在其他工作日,我們采用以下邏輯:
- In the weekend, choose a difficult recipe 在周末,選擇困難的食譜
- During the week, when I’m at home or my wife has a day off, choose a recipe with medium difficulty 在一周中,當我在家或我的妻子休息一天時,選擇中等難度的食譜
- During the week, when I or my wife are at work, choose an easy recipe 在本周,當我或妻子上班時,選擇簡單的食譜
將周菜單添加到Google日歷 (Adding the week menu to a Google Calendar)
Now that we have a menu for the coming week, we can add it as events to a Google Calendar. I’ve created a separate calendar for it. Share this calendar with the client_email in credentials.json. In the settings of your calendar you also need to give it permission to make changes in the events.
現(xiàn)在我們有了下周的菜單,我們可以將其作為事件添加到Google日歷中。 我為此創(chuàng)建了一個單獨的日歷。 將此日歷與憑據(jù)中的client_email共享。 在日歷的設(shè)置中,您還需要授予其更改事件的權(quán)限。
def add_weekmenu_to_calendar(service, weekmenu_df, calendarId):for i, r in weekmenu_df.iterrows():event = {'summary': r.recipe,'description': r.description,'start': {'date': i.date().isoformat(),'timeZone': 'Europe/Brussels'},'end': {'date': i.date().isoformat(),'timeZone': 'Europe/Brussels'}}event = service.events().insert(calendarId=calendarId, body=event).execute()讓我們自動化 (Let’s automate)
Until now we have taken into account all the requested features for the application. But you would still have to run the code by hand to generate the week menu.
到目前為止,我們已經(jīng)考慮了該應(yīng)用程序所有要求的功能。 但是您仍然必須手動運行代碼才能生成星期菜單。
I found this great website PythonAnyWhere where you can schedule Python programs. The free Beginner account allows to schedule one Python program on a daily basis. That’s exactly what we need.
我找到了這個很棒的網(wǎng)站PythonAnyWhere ,您可以在其中安排Python程序。 免費的初學(xué)者帳戶允許每天安排一個Python程序。 這正是我們所需要的。
First, we need to stitch all the functions together and put them in a Python file. In this file, I do an extra check to see where we are in the current week menu. I do this by looking at the last date with a recipe in the Google Calendar with get_date_last_event.
首先,我們需要將所有功能拼接在一起,并將它們放入Python文件中。 在此文件中,我進行了額外的檢查,以查看當前周菜單中的位置。 為此,我會使用get_date_last_event.在Google日歷中g(shù)et_date_last_event.食譜的最后日期get_date_last_event.
def get_date_last_event(service, calendarId):events_result = service.events().list(calendarId=calendarId, singleEvents=True, orderBy='startTime').execute()date_last_event = events_result.get('items', [])[-1]['start']['date'][:10]date_last_event = datetime.strptime(date_last_event, '%Y-%m-%d').date()return date_last_eventThat date is stored in DATE_LAST_RECIPE. If the current day is after DATE_LAST_RECIPE minus NB_DAYS_BEFORE we can generate a new week menu.
該日期存儲在DATE_LAST_RECIPE. 如果當前日期是DATE_LAST_RECIPE減去NB_DAYS_BEFORE我們可以生成一個新的星期菜單。
You can find the complete script on Github.
您可以在Github上找到完整的腳本。
if __name__ == '__main__':# Getting credentials from credentials.jsonCREDS_PATH = Path.cwd() / "weekmenu" / "credentials.json"creds = service_account.Credentials.from_service_account_file(CREDS_PATH, scopes=cfg.SCOPES)# Creating service objectsservice_cal = build('calendar', 'v3', credentials=creds)service_sheet = build('sheets', 'v4', credentials=creds)# Defining datesDATE_LAST_RECIPE = get_date_last_event(service_cal, cfg.CALENDARID_WEEKMENU) START_DAY = DATE_LAST_RECIPE + timedelta(days=1)NEXT_WEEK = START_DAY + timedelta(days=6)PREV_WEEK = START_DAY + timedelta(days=-7)START_DAY = format_date(START_DAY)NEXT_WEEK = format_date(NEXT_WEEK)PREV_WEEK = format_date(PREV_WEEK)# Getting the recipes from the Google Sheetrecipes_df, eligible_recipes = get_recipes(service_sheet, cfg.SPREADSHEET_ID, cfg.RANGE)# Check if the last weekmenu is still activeif DATE_LAST_RECIPE - timedelta(days=cfg.NB_DAYS_BEFORE) < datetime.now().date():# Getting the events from the Google Calendarsevents_list_1 = get_events_by_calendarId(service_cal, cfg.CALENDARID_1, START_DAY, NEXT_WEEK, cfg.ALL_EVENTS)events_list_2 = get_events_by_calendarId(service_cal, cfg.CALENDARID_2, START_DAY, NEXT_WEEK, cfg.ALL_EVENTS)# Merge the two events listsevents_df = create_events_df(events_list_1, events_list_2)# Generating the weekmenuweekmenu_df = generate_weekmenu(service_sheet, events_df, cfg.TRADITIONS, cfg.FREE_EVENTS)# Adding the weekmenu to a Google Calendaradd_weekmenu_to_calendar(service_cal, weekmenu_df, cfg.CALENDARID_WEEKMENU)print('Week menu is added to Google Calendar')else:print('Program stopped. Last week menu is not finished yet.')On PythonAnyWhere I’ve created a subfolder week menu. I’ve uploaded the following files config.py, generate_weekmenu.py and credentials.json.
在PythonAnyWhere上,我創(chuàng)建了一個子文件夾的周菜單。 我已經(jīng)上傳了以下文件config.py,generate_weekmenu.py和憑據(jù).json。
I then schedule a daily task that will run the generate_weekmenu.py script in the Tasks section. And voilà, we’re all set.
然后,我安排一個日常任務(wù),該任務(wù)將在“任務(wù)”部分中運行g(shù)enerate_weekmenu.py腳本。 瞧,我們都準備好了。
結(jié)果 (The result)
After the first run of the script, we have a nice menu in our shared Google calendar.
第一次運行腳本后,我們在共享的Google日歷中有一個漂亮的菜單。
結(jié)論 (Conclusion)
This script takes into account your professional schedule on your Google calendars. It selects your preferred recipes from a Google sheet. And by scheduling the script the recipes appear in an automated way in your Google Calendar. This frees you from the annoying chore to decide what to eat.
該腳本考慮了您在Google日歷上的專業(yè)日程安排。 它從Google表格中選擇您喜歡的食譜。 通過安排腳本,配方可以自動顯示在Google日歷中。 這使您從煩惱的瑣事中解放出來,決定吃什么。
If you want to take it further, here are some ideas to fine-tune the script:
如果您想進一步講解,這里有一些想法可以對腳本進行微調(diào):
- take into account the cooking time of a recipe 考慮食譜的烹飪時間
- allow a tradition of having at least one vegetarian meal per week 允許每周至少吃一頓素食的傳統(tǒng)
- generate a grocery list for the chose recipes 生成所選食譜的購物清單
I hope you enjoyed reading this story. If you have questions or suggestions about the script you can write a comment below. And if you liked it, feel free to clap for it.
希望您喜歡閱讀這個故事。 如果您對腳本有疑問或建議,可以在下面寫評論。 而且,如果您喜歡它,可以隨時為它鼓掌。
翻譯自: https://www.freecodecamp.org/news/how-to-save-time-and-money-by-building-an-automatic-meal-planner-7c7a9351d124/
如何制作營養(yǎng)膳食計算器
總結(jié)
以上是生活随笔為你收集整理的如何制作营养膳食计算器_如何通过构建自动膳食计划器节省时间和金钱的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 腾讯QQ精准TIPS消息营销介绍
- 下一篇: UiPath PDF数据提取