You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The sys module contains most of the information relating to the current execution, as well as a series of basic functions and objects of the low level.
2150
+
2151
+
**argv**
2152
+
2153
+
Contains the list of parameters of a given script. The first element of the listis the name of the script(.py) followed by the list of parameters.
2154
+
2155
+
**executable**
2156
+
2157
+
Returns the path of the Python interpreter.
2158
+
2159
+
```python
2160
+
>>> sys.executable
2161
+
'/home/.../bin/python3'
2162
+
```
2163
+
2164
+
**exc_info**
2165
+
2166
+
Returns a tuple contains the type of exception, the instance of the exception, and the traceback object(sys.last_type, sys.last_value, sys.last_traceback).
2167
+
2168
+
```python
2169
+
>>>import sys
2170
+
>>> sys.exc_info()
2171
+
(None, None, None)
2172
+
>>>try:
2173
+
...a=input()
2174
+
...a= a/3
2175
+
...except:
2176
+
...print(sys.exc_info())
2177
+
...
2178
+
qwe
2179
+
(<class'TypeError'>, TypeError("unsupported operand type(s) for /: 'str' and 'int'"), <traceback object at 0x7f13b8ccb690>)
2180
+
2181
+
>>> sys.last_type
2182
+
<class'TypeError'>
2183
+
>>> sys.last_value
2184
+
TypeError("unsupported operand type(s) for /: 'str' and 'int'")
2185
+
>>> sys.last_traceback
2186
+
<traceback object at 0x7f13b8ccb690>
2187
+
```
2188
+
2189
+
**platform**
2190
+
2191
+
Returns the type of the current running platform.
2192
+
2193
+
```python
2194
+
>>> sys.platform
2195
+
'linux'
2196
+
```
2197
+
2198
+
**builtin_module_names**
2199
+
2200
+
Returns a tuple of strings containing the names of all available modules.
Returns 'big'if the bits are in most significant order(big-Endian), and'little'if it isin least significant order(little-Endian).
2212
+
2213
+
```python
2214
+
>>> sys.byteorder
2215
+
'little'
2216
+
```
2217
+
2218
+
**maxsize**
2219
+
2220
+
Returns an integer that represents the maximum value a variable can have. In a 32-bit platform, the value is usually 2**33-1 (2147483647), andin a 64-bit platform it is2**63-1 (9223372036854775807).
2221
+
2222
+
```python
2223
+
>>> sys.maxsize
2224
+
9223372036854775807
2225
+
```
2226
+
2227
+
**version**
2228
+
2229
+
Returns the version of the Python interpreter.
2230
+
2231
+
```python
2232
+
>>> sys.version
2233
+
'3.7.6 (default, Jan 8 2020, 19:59:22) \n[GCC 7.3.0]'
2234
+
```
2235
+
2236
+
**version_info**
2237
+
2238
+
Returns a tuple containing five version number components.
0 commit comments