1. 程式人生 > >Python錯誤:AttributeError: module 'signal' has no attribute 'SIGALRM'

Python錯誤:AttributeError: module 'signal' has no attribute 'SIGALRM'

電腦系統是win10 64位,在使用python的signal模組時報錯:“AttributeError: module 'signal' has no attribute 'SIGALRM'”,這是因為signal模組可以在linux下正常使用,但在windows下卻有一些限制,在python文件https://docs.python.org/2/library/signal.html#signal.signal找到了如下解釋:

"On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any other case."

也就是說在windows下只能使用這幾個訊號:

  • SIGABRT
  • SIGFPE
  • SIGILL
  • SIGINT
  • SIGSEGV
  • SIGTERM

參考: