Python 查找要从dict中删除的用户数据的方法?

Python 查找要从dict中删除的用户数据的方法?,python,python-3.x,Python,Python 3.x,试图根据用户的输入提取特定信息。一旦信息被提取,它将被删除。信息存储在列表中的词典中。截至目前,我掌握的情况如下: if selection == '3': print('Please enter in the information of the user you are looking for:\n') remove_first_name = input("User's first name:\t") remove_last_name = input("User's

试图根据用户的输入提取特定信息。一旦信息被提取,它将被删除。信息存储在列表中的词典中。截至目前,我掌握的情况如下:

if selection == '3':
    print('Please enter in the information of the user you are looking for:\n')
    remove_first_name = input("User's first name:\t")
    remove_last_name = input("User's last name:\t")

    for item_to_delete in all_users:
        if item_to_delete['First name'] == remove_first_name and item_to_delete['Last name'] == remove_last_name:
            delete_item = item_to_delete
                input('Is this the user you are looking for?\t', delete_item)
                break
        else:
            print('Sorry. There is no user found with that information. Please try again')
            delete_item = None
运行时,我遇到以下错误:

回溯(最近一次呼叫最后一次):
文件“/home/muturi/Test_File.py”,第69行,在
输入('这是您要查找的用户吗?\t',删除\u项)
TypeError:输入最多需要1个参数,得到2个
非常感谢您提供的任何帮助。

输入()方法只需要1个参数,但您需要2个参数。在将问题传递给
input()
方法之前,应该先格式化问题。因此:

input("Is this the user you're lookinf for?\t%s" % (delete_item))
这将用
delete\u item
的值替换字符串中的
“%s”
。然后,
input()
方法只接收一个参数。
input()
方法只需要一个参数,但您给它两个参数。在将问题传递给
input()
方法之前,应该先格式化问题。因此:

input("Is this the user you're lookinf for?\t%s" % (delete_item))
这将用
delete\u item
的值替换字符串中的
“%s”
。然后,
input()
方法只接收一个参数。

input()
只接受一个参数。如果您试图确认要删除的项目是否正确,请使用:

delete_item = {"a": 1, "b": 2}
>>> input('Is this the user you are looking for?\t' + str(delete_item))
Is this the user you are looking for?   {'a': 1, 'b': 2}
''
>>> 

input()
只接受一个参数。如果您试图确认要删除的项目是否正确,请使用:

delete_item = {"a": 1, "b": 2}
>>> input('Is this the user you are looking for?\t' + str(delete_item))
Is this the user you are looking for?   {'a': 1, 'b': 2}
''
>>> 

input()
只需要一个参数。为什么要将
delete\u项传递给它?要将输入带入变量,请使用赋值
delete\u item=input(…)
,正如您从for
input()
中看到的,它只接受一个参数。
input()
只需要一个参数。为什么要将
delete\u项传递给它?要将输入带入变量,请使用赋值
delete\u item=input(…)
,从for
input()
,它只接受一个参数。