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
出現這樣的:你在Python 2.7提供的「作品」行號或堆棧跟蹤將是有益的Python的sqlite3的錯誤
Can't convert 'int' object to str implicitly
來自用戶的輸入被認爲是一個字符串,因此將其轉換爲int應該可以正常工作。你可以給出關於錯誤的輸出的其餘部分。 – KingJohnno
大多數情況下,當你試圖連接一個字符串和一個整數時,會看到這個錯誤:例如:''1'+ 1' - >'TypeError:不能將'int'對象隱式轉換爲str,所以檢查你的代碼對於這樣的錯誤。 –
打印(今天) SQL =( 「INSERT INTO咖啡館()VALUES( ' 」+諾姆+「', ' 」+ NOTA +「', ' 」+數據+「')」) \t cursor.execute(SQL) \t cursor.commit() \t geraMenu() 這是其餘的 – Isaias20