类型错误:在python中使用pywhatkit时,'int'对象无法调用面对此错误



我正在创建一个个人助理,我正在使用python中的pywhatkit模块自动化whatsapp聊天,突然得到了这个错误,在工作了很多小时后无法修复。谁来帮帮我。我能做些什么来解决这个问题?

代码:

elif 'send a message' in query:
speak("tell me the phone number")
phone = str(takecommand())
speak("tell me the message")
message = str(takecommand())
speak("when should i send message")
speak("ntime in hours")
time_hour = int(takecommand())
speak("time in minutes")
time_min = int(takecommand())
speak("how much should I wait before sending message")
wait_time = int(takecommand())
kit.sendwhatmsg(f"+91{phone}", message , time_hour(), time_min(), wait_time())
speak("Ok sir! sending message")

我收到错误(运行程序后):

User said: send a message

: tell me the phone number
Listening...
recognizing
User said: xxxx xxx xxx

: tell me the message
Listening...
recognizing
User said: testing

: when should i send message

: 
time in hours
Listening...
recognizing
User said: 21

: time in minutes
Listening...
recognizing
User said: 24

: how much should I wait before sending message
Listening...
recognizing
User said: 20
Traceback (most recent call last):
File "e:AI Chat BotProject JARVISjarvis.py", line 122, in <module>
kit.sendwhatmsg(f"+91{phone}", message , time_hour(), time_min(), wait_time())
TypeError: 'int' object is not callable

当变量为整数时,您试图将其作为函数调用。

改变这一行…

kit.sendwhatmsg(f"+91{phone}", message , time_hour(), time_min(), wait_time())

这个…

kit.sendwhatmsg(f"+91{phone}", message , time_hour, time_min, wait_time)

相关内容