Python: Difference between revisions

From Halfface
Jump to navigation Jump to search
Line 12: Line 12:
Import functions.
Import functions.
  import $module
  import $module
=try:=
Exception handling. Example will fail because x is unset.
try:
  print(x)
except:
  print("An exception occurred")

Revision as of 20:26, 26 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")