Python Basics Sys Exit Method

preview_player
Показать описание
Learn how to use the exit method from the sys module for python programming

twitter: @python_basics
Рекомендации по теме
Комментарии
Автор

thank you, i was stuck and this resolved my problem

mrmoney
Автор

Thank you very much, it was very useful!

tuliohernandez
Автор

Hello I am a beginner who is learning python but I just don't know what sys.exit() does. Could you explain it to me?
Anyway have a nice day and great video!

koekoeksklokd
Автор

and how do you end an application that has more than more than one thread?? sys.exit(0) ends the program, except for the thread and the problem is that the thread cannot check if it is supposed to end, only another function that literally has nothing to do with the thread shall end.
Here my code:
from pynput.keyboard import Key, Controller, Listener
import itertools
from tabulate import tabulate
import time
import threading
import sys

keyboard = Controller()
combinationen = list(itertools.product([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], repeat=4))

def thread2():
time.sleep(2)
string = ""
for x in range(0, 10000):
for integer in combinationen[x]:
keyboard.press(str(integer))

keyboard.press(Key.enter)
time.sleep(0.5)

thread01 =
thread01.start()

def on_press(key):
if key == Key.shift:
print("KEY PRESSED")
sys.exit(0)

with Listener(on_press=on_press) as listener:
listener.join()


(Yes, it is a brute force script but it's only for educational use trust me!)

sesamtoast