PythonSQLite3错误 def menuadiciana(): nome=输入(“Digite o nome de quem fez o cafe:”) nota=int(输入(“Que nota recebeu:”) 如果len(str(nome).strip())==0: menuAdiciona() 如果(nota)==0: menuAdiciona() 如果notaTypeError:无法隐式地将'int'对象转换为str,因此请检查您的代码是否存在此类错误。print(今日)sql=(“INSERT-INTO-cafe()值(“+nome+”,”+nota+“,”“+data+“)”)游标。执行(sql)游标。提交()菜单()这是REST。用户的输入被视为字符串,因此将其转换为int应该可以。请给出关于错误的其余输出。当您尝试连接字符串和整数时,通常会看到此错误:例如:'1'+1-->TypeError:无法隐式地将'int'对象转换为str,因此请检查您的代码是否存在此类错误。print(今日)sql=(“INSERT-INTO-cafe()值(“+nome+”,”+这是restHey jedwards你能给我发封电子邮件吗?我想把我的节目发给你会更容易,你看起来也很好。如果你有时间,请。伊萨亚斯_duarte7@hotmail.comHey你能给我发封电子邮件吗?我想把我的节目发给你会更容易,你看起来也很好。如果你有时间,请。伊萨亚斯_duarte7@hotmail.com
显示如下: 无法将“int”对象隐式转换为strPythonSQLite3错误 def menuadiciana(): nome=输入(“Digite o nome de quem fez o cafe:”) nota=int(输入(“Que nota recebeu:”) 如果len(str(nome).strip())==0: menuAdiciona() 如果(nota)==0: menuAdiciona() 如果notaTypeError:无法隐式地将'int'对象转换为str,因此请检查您的代码是否存在此类错误。print(今日)sql=(“INSERT-INTO-cafe()值(“+nome+”,”+nota+“,”“+data+“)”)游标。执行(sql)游标。提交()菜单()这是REST。用户的输入被视为字符串,因此将其转换为int应该可以。请给出关于错误的其余输出。当您尝试连接字符串和整数时,通常会看到此错误:例如:'1'+1-->TypeError:无法隐式地将'int'对象转换为str,因此请检查您的代码是否存在此类错误。print(今日)sql=(“INSERT-INTO-cafe()值(“+nome+”,”+这是restHey jedwards你能给我发封电子邮件吗?我想把我的节目发给你会更容易,你看起来也很好。如果你有时间,请。伊萨亚斯_duarte7@hotmail.comHey你能给我发封电子邮件吗?我想把我的节目发给你会更容易,你看起来也很好。如果你有时间,请。伊萨亚斯_duarte7@hotmail.com,python,sqlite,Python,Sqlite,显示如下: 无法将“int”对象隐式转换为str 首先,您提供的代码在Python2.7和3中“起作用” 行号或stacktrace可能会有所帮助,但假设它位于您提供的代码段中: def menuAdiciona(): nome = input("Digite o nome de quem fez o cafe: ") nota = int(input("Que nota recebeu: ")) if len(str(nome).strip()) == 0:
首先,您提供的代码在Python2.7和3中“起作用” 行号或stacktrace可能会有所帮助,但假设它位于您提供的代码段中:
def menuAdiciona():
nome = input("Digite o nome de quem fez o cafe: ")
nota = int(input("Que nota recebeu: "))
if len(str(nome).strip()) == 0:
menuAdiciona()
if (nota) == 0:
menuAdiciona()
if nota < 0:
nota = 0
这里nota
是一个int
nota = int(input("Que nota recebeu: "))
下一行您试图将其转换为字符串,但未指定如何转换
比如:
if len(str(nome).strip()) == 0:
应该可以防止错误
尽管如此,这句话仍然没有什么意义。您不必strip()
整数的字符串表示形式
使用strip()
和如果len(…)==0
部分,您试图实现什么
编辑:最后,我认为您需要
raw\u input()
而不是input()
,除非您也在某个地方跟踪它。首先,您提供的代码在Python 2.7和3中“起作用”
行号或stacktrace可能会有所帮助,但假设它位于您提供的代码段中:
def menuAdiciona():
nome = input("Digite o nome de quem fez o cafe: ")
nota = int(input("Que nota recebeu: "))
if len(str(nome).strip()) == 0:
menuAdiciona()
if (nota) == 0:
menuAdiciona()
if nota < 0:
nota = 0
这里nota
是一个int
nota = int(input("Que nota recebeu: "))
下一行您试图将其转换为字符串,但未指定如何转换
比如:
if len(str(nome).strip()) == 0:
应该可以防止错误
尽管如此,这句话仍然没有什么意义。您不必strip()
整数的字符串表示形式
使用strip()
和如果len(…)==0
部分,您试图实现什么
编辑:最后,我认为您需要
raw\u input()
而不是input()
,除非您也将其隐藏在某个地方。用户的输入被视为字符串,因此将其转换为int应该可以。请给出关于错误的其余输出。当您尝试连接字符串和整数时,通常会看到此错误:例如:'1'+1
-->TypeError:无法隐式地将'int'对象转换为str
,因此请检查您的代码是否存在此类错误。print(今日)sql=(“INSERT-INTO-cafe()值(“+nome+”,”+nota+“,”“+data+“)”)游标。执行(sql)游标。提交()菜单()这是REST。用户的输入被视为字符串,因此将其转换为int应该可以。请给出关于错误的其余输出。当您尝试连接字符串和整数时,通常会看到此错误:例如:'1'+1
-->TypeError:无法隐式地将'int'对象转换为str
,因此请检查您的代码是否存在此类错误。print(今日)sql=(“INSERT-INTO-cafe()值(“+nome+”,”+这是restHey jedwards你能给我发封电子邮件吗?我想把我的节目发给你会更容易,你看起来也很好。如果你有时间,请。伊萨亚斯_duarte7@hotmail.comHey你能给我发封电子邮件吗?我想把我的节目发给你会更容易,你看起来也很好。如果你有时间,请。伊萨亚斯_duarte7@hotmail.com