Python和API用户输入

问题描述 投票:0回答:1

我的代码是

import requests
from pprint import pprint

from pip._vendor.distlib.compat import raw_input

recipe_ingredients = input("What is the recipe ingredients? ")
number_recipes = input("How many recipes do you want? ")
url = 'https://api.spoonacular.com/recipes/findByIngredients?ingredients={}&number={}&'.format(recipe_ingredients,number_recipes)

response = requests.get(url)
print(response)

但是,当我以(两种成分)奶酪格式输入多个成分时,它返回第一个变量的结果,或者告诉我存在语法错误。

有什么方法可以对搜索功能进行编程以接受and,从而可以显示两个单词的所有结果,因为用户很可能会将“ and”放在搜索中,而不是一种成分。

((我正在使用pycharm btw)

python api input syntax
1个回答
0
投票
您可以通过以下方式修复它:
© www.soinside.com 2019 - 2024. All rights reserved.