Why can't exit () be executed when the following code is executed with python?Applicable source code
>>>try: ... eval ("exit ()") ... except: ... print ("exception") ... exception
eval ("exit ()") itself can be executed.
>>>eval ("exit ()") C: \ Users \ usrname>
Below is executable.
>>>try: ... eval ("print (\" Hello \ ")") ... except: ... print ("exception") ... Hello
Answer # 1
In this case, the existence of eval is irrelevant. Reproduce with the following code:
>>>try: ... exit () ... except: ... print ('spam') ... spam
This exit originates from the site module and raises an exception SystemExit when called.
exit (code = None)
An object that displays a message such as"Use quit () or Ctrl-D (i.e. EOF) to exit"when it is displayed, and dispatches a SystemExit with the specified exit code when called.
Source: Python Standard Library »Constants added in the site module-exit
Answer # 2
If it's not an interactive shell, it's in sys.
- python - my gpu is recognized, but i can't use it
- python - i can't install unittest2
- python - i installed pygame, but i can't use it
- python 3x - can't get multiple pages of data
- python 3x - i can't understand the code
- python - why does it work without any arguments?
- python 3x - i can't get the correct answer
- python 3x - can't do some python scraping
- python - can't open with subprocesspopen question
- python - how to use try and continue
- python - i can't play mp3 in pygame
- python - i can't understand the code
- can't install mecab-python3
- python - can't i get the select data with requestformget?
- python - why you need exception handling
- python - lighttpd can't be started up
- python 3x - why dare to write if __name__ =='__main__':?
- python - i can't spit out the package list to text with pip
- python - why virtualenv exists
- python - can't get channel with discord
- python - if a specific button (eg root) is pressed, execute the process that was stopped
- python: how to change the print format of the answer obtained with return
- python - order django admin categories alphabetically
- python - i'm in trouble because i don't understand atcoder146d
- python - unicodedecodeerror when installing pip on windows
- python - missing 1 required positional argument
- python - i created an ssl authentication detection program, but an exception occurred
- python - reason why certificate information is returned even though it is not https
- python - collect data every n seconds with pandas and process for each column
- how to use boolean type in python