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 3x - i can't install pyinstaller with pip install
- python - why an attributeerror occurs
- 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 - i can't play mp3 in pygame
- python - my gpu is recognized, but i can't use it
- i can't import cv2 and os in python
- python - why is it not printed?
- i can't run python through php
- python - i can't putitem for dynamodb
- python - can't deploy to heroku
- python - [django] i can't log in for some reason
- i installed python, but can't run it
- i can't run python with cron
- python 3x - can't get data with python scraping
- python - i can't import
- python - i can't read the error message
- python - how to remove a list from a tuple and store only the value
- http error 503: service unavailable when doing amazon scraping with python
- python - i want to simplify the program that sequentially retrieves from the list
- python - regarding the problem that tries to decompose a string apostrophe using a dictionary but fails
- python - common behavior for everything in django
- python - i want to split one array into two without duplication
- about the problem that float subtraction does not work in numerical calculation in python
- python - something went wrong in the jupiter lab
- python - how to deal with error when converting pandas datetime type
- i want to read python time series data while shifting by 1 day