我有允許用戶點擊日曆並輸出日期的代碼。我想把日期鏈接到一個SQL查詢,但有錯誤:TypeError:int()參數必須是字符串,類似字節的對象或數字,而不是'Calendar'
File "C:\Users\dansi\AppData\Local\Programs\Python\Python36-32\gui test 3.py", line 293, in datefunction
agro = int(agro)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'Calendar'
代碼的問題:
def datefunction(self,agro):
print(agro)
agro = int(agro)
agro = datetime.datetime(agro)
timeslot = cursor.execute('''SELECT * FROM dates WHERE Date = (?)''',(agro,))
list1 = list(cursor.fetchall())
print(list1)
def _show_selection(self, text, bbox):
"""Configure canvas for a new selection."""
agro = self.selection
print(self.selection, self.datefunction())
print(agro)
比方說,用戶點擊在3月3日,它會輸出
'2017-03-03 00-00-00'
如何才能克服這個錯誤?
你'datefunction'沒有'self'你可以解決它你也不會給它一個「agro」... –
@WillemVanOnsem由於某種原因,它在我的代碼上,但不在這裏 – simons21
你是什麼意思?我不明白你說什麼。 –