Python

From Halfface
Revision as of 18:42, 27 April 2021 by Ekaanbj (talk | contribs) (→‎try:)
Jump to navigation Jump to search

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.