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

Asked 2 weeks ago, Updated 2 weeks ago, 1 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?


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):

signal.signal(signal.SIGINT, signal_handle)

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

2022-09-20 14:39

If you have any answers or tips

© 2022 pinfo. All rights reserved.