Erro-Python“str”对象不可调用

Erro-Python“str”对象不可调用,python,Python,我有题目的错误,你能帮我吗 while (True and not False): print(''' +-------------------------------------------------------------+ | CRUD - Python com SQLite3 | | 1. Create

我有题目的错误,你能帮我吗

while (True and not False):
    print('''
    +-------------------------------------------------------------+
    |                  CRUD - Python com SQLite3                  |
    | 1. Create                                                   |
    | 2. Read                                                     |
    | 3. Update                                                   |
    | 4. Delete                                                   |
    | 5. Criar Tabela                                             |
    | Use os comandos do SQLite3!                                 |
    | Input < 1 and > 5. Sair                                     |
    +-------------------------------------------------------------+
    ''')
    input = input('Selecione uma opção: ')
    if input == '1':
        sql = input("Digite o comando para INSERIR: ")
        inserir(sql)
    if input == '2':
        sql = input("Digite o comando SELECT:")
        select(sql)
    if input == '3':
        print('0')
    if input == '4':
        print('0')
    if input == '5':
        sql = input("Digite o comando para criar tabela: ")
        sql = criarTabela(sql)
    else:
        exit(0)
多谢各位 无论何时运行,错误都会出现在以下行中: sql=输入“blabla”

你写一行:

input = input('Selecione uma opção: ')
但这将覆盖输入函数:现在输入将指向您输入的字符串。你不能调用字符串

您应该重命名变量,例如使用foo:


您应该为input=input使用另一个名称。在这里,你用实际输入覆盖输入函数。FWIW,while条件很奇怪。你的if可以是elif,除了第一个,你能举个例子吗,如果你不打扰你的话?
while True:
    print('''
    +-------------------------------------------------------------+
    |                  CRUD - Python com SQLite3                  |
    | 1. Create (Inserir dado em uma tabela)                      |
    | 2. Read (Select, lista os dados de uma tabela)              |
    | 3. Update (Atualiza uma tupla ou um atributo)               |
    | 4. Delete (Remove uma tupla de uma tabela)                  |
    | 5. Criar Tabela                                             |
    | Use os comandos do SQLite3!                                 |
    | Input < 1 and > 5. Sair                                     |
    +-------------------------------------------------------------+
    ''')
    foo = input('Selecione uma opção: ')
    if foo == '1':
        sql = input("Digite o comando para INSERIR: ")
        inserir(sql)
    if foo == '2':
        sql = input("Digite o comando SELECT:")
        select(sql)
    if foo == '3':
        print('0')
    if foo == '4':
        print('0')
    if foo == '5':
        sql = input("Digite o comando para criar tabela: ")
        sql = criarTabela(sql)
    else:
        exit(0)