Linux下:
使用 timeout Ns(N是執行的秒數)命令。
timeout 3s op_statement_do_somthing.
Python中使用os.sysytem('timeout 3s op_statement_do_somthing.')
其他方法(僅限Linux):
https://stackoverflow.com/questions/52779920/why-is-signal-sigalrm-not-working-in-python-on-windows
https://stackoverflow.com/questions/8420422/python-windows-equivalent-of-sigalrm
https://www.jb51.net/article/154525.htm