python中sys exit 1 和sys exit 1 有什麼區別?

時間 2021-06-02 07:13:39

1樓:黃哥

先看help 文件

exit([status])

Exit the interpreter by raising SystemExit(status).

If the status is omitted or None, it defaults to zero (i.e., success).

If the status is an integer, it will be used as the system exit status.

If it is another kind of object, it will be printed and the system

exit status will be one (i.e., failure).

exit() 不傳引數時,預設傳0

exit() 引數為整數,it will be used as the system exit status。

sys.exit(-1)tells the program to quit. It basically just stops the python code from continuing execution.

-1 is just the status code that is passed in. Generally 0 denotes successful execution, any other number (usually 1) means something broke.

The callsys.exit(n)tells the interpreter to stop the execution and returnnto the OS. What this value is depends on the operating system.

For example on UNIX ($?is the last exit status):

I want to know what exactly sys.exit(-1) returns in python?

python中 list1 append list list2 與list1 append list2 的區別是深拷貝麼?

謝藥 l1 300,311 la lb id l1 4510553440 id la 0 4510553440 id lb 0 4510613448 id l1 0 140290197409840 id l1 1 140290197409912 id la 0 0 140290197409840 i...

Python中reshape函式引數 1的意思?

西紅柿雞蛋湯 首先要明白shape的含義,shape代表了乙個矩陣的行和列。比如這個矩陣,m np.array 1,2 3 5,6,7 m.shape 它的shape是 3,2 reshape就是對矩陣的shape重新排列。比如m.reshape 3,2 1 2 3 5 6 7 我們就將矩陣重新排列...

Python中id a ,3,True, scd 1 id 3 ,為啥是true?

之乎者也 這個問題轉化為簡單直觀的說法就是列表中的3和普通的3的id為啥是一樣的。首先需要知道Python採用的是引用計數,舉個栗子。a 3和b 3 這兩個的3其實是一樣的,可以理解為這個3在記憶體中放著,然後ab都把它拿過來用。這就是python的引用機制的獨特的地方了,換做C語言這兩個肯定是不一...