当我尝试使用datetime.datetime.now()
将时间添加到文件名时,我得到:'OSError:[Errno 123] other os error'
我尝试使用time.time()
,但是我觉得这是不必要的,因为datetime.datetime.now()
可以抽出时间...
shot.save(path+'//'+str(datetime.datetime.now())+'.png')
错误:
Unhandled exception in listener callback
Traceback (most recent call last):
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pynput\_util\__init__.py", line 162, in inner
return f(self, *args, **kwargs)
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pynput\keyboard\_win32.py", line 240, in _process
self.on_press(key)
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pynput\_util\__init__.py", line 78, in inner
if f(*args) is False:
File "C:\Users\SQ\Desktop\Screenshot\02.pyw", line 8, in on_press
check_key(key)
File "C:\Users\SQ\Desktop\Screenshot\02.pyw", line 25, in check_key
shot.save(path+'//'+str(datetime.datetime.now())+'.png')
OSError: [Errno 123] other os error
Traceback (most recent call last):
File "C:\Users\SQ\Desktop\Screenshot\02.pyw", line 40, in <module>
listener.join()
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pynput\_util\__init__.py", line 210, in join
six.reraise(exc_type, exc_value, exc_traceback)
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\six.py", line 692, in reraise
raise value.with_traceback(tb)
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pynput\_util\__init__.py", line 162, in inner
return f(self, *args, **kwargs)
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pynput\keyboard\_win32.py", line 240, in _process
self.on_press(key)
File "C:\Users\SQ\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pynput\_util\__init__.py", line 78, in inner
if f(*args) is False:
File "C:\Users\SQ\Desktop\Screenshot\02.pyw", line 8, in on_press
check_key(key)
File "C:\Users\SQ\Desktop\Screenshot\02.pyw", line 25, in check_key
shot.save(path+'//'+str(datetime.datetime.now())+'.png')
OSError: [Errno 123] other os error
[Finished in 5.6s with exit code 1]
[shell_cmd: python -u "C:\Users\SQ\Desktop\Screenshot\02.pyw"]