Python: Difference between revisions
Jump to navigation
Jump to search
(→try:) |
|||
Line 20: | Line 20: | ||
=sys.exit()= | =sys.exit()= | ||
exits and no stack traceback is printed. | exits and no stack traceback is printed. | ||
=re= | |||
Regular expression searching | |||
ip = re.findall(r'[0-9]+(?:\.[0-9]+){3}', config_info) |
Revision as of 20:57, 27 April 2021
version
Show python version
python -V
make an http request
import requests r =requests.get('https://halfface.se') print(r.text)
dictionary
dictionary = {"a": 99, "hello": "world"}
import
Import functions.
import $module
try:
Exception handling. Example will fail because x is unset.
try: print(x) except: print("An exception occurred")
sys.exit()
exits and no stack traceback is printed.
re
Regular expression searching
ip = re.findall(r'[0-9]+(?:\.[0-9]+){3}', config_info)