Do not interrupt the keyboard when you type ctrl c on the Python console screen

Asked 2 years ago, Updated 2 years ago, 19 views

I'm using Python code as an application with pyinstaller.

There are times when you copy and paste messages that appear on the console, and pressing ctrl c several times to copy causes the window to turn off.

Can I set the key to ignore when I press ctrl c or to exit the process to a different key?

python

2022-09-20 14:39

1 Answers

CTRL+C is to send a SIGINT signal to the process, so you can write a corresponding code for the signal.

import signal

def signal_handle(signum, f):
    pass

signal.signal(signal.SIGINT, signal_handle)

while(True):
    q = input("enter : ")
    if q is not '': print(f":D {q}")


2022-09-20 14:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.