Python Examples of zlib.crc32Cyclic redundancy check
A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to digital data.
Using zlib.crc32 Function
Computes a C...
Secure hashes and message digests.Hash algorithms
The hashlib module implements a common interface to many different secure hash and message digest algorithms. Included are the FIPS secure hash algorithms SHA1, SHA224, SHA256, SHA384, and SHA512 (def...
Fetch Internet Resources Using The urllib Package.Fetching URLs
The simplest way to use urllib.request is as follows:
#!/usr/bin/env python3
# Import datetime module
import urllib.request
with urllib.request.urlopen('https://google.com') as respon...
Python String Formatting Best Practices.Fancier Output Formatting
To use formatted string literals, begin a string with f or F before the opening quotation mark or triple quotation mark. Inside this string, you can write a Python expression between {...
String Constants Best Practice.String Constants in Python
The constants defined in this module are:
String constants:
string.ascii_lettersThe concatenation of the ascii_lowercase and ascii_uppercase constants described below. This value is not locale...
Converting Json to string in Python.Decoding JSON
To convert string to json in Python, use the json.loads() function. The json.loads() is a built-in Python function that accepts a valid json string and returns a dictionary to access all elements. The...
Does Python have a string 'contains' substring method?.Using the in Operator
The easiest way to check if a Python string contains a substring is to use the in operator.
str = "Python"
if "th" in str:
print("Found!")
# case-insensitive
if "TH" no...
Check if a given key already exists in a dictionary.Using the in operator
In this method, we use the membership operator in. This operator is used to check if one value is a member of another. It returns a boolean value.
dict = {"GMT": 0, "BST": 1}
...
Python’s Core Data Types.Core Data Types
The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions.
Built-in objects preview:
Object type:
Numbersint, float, complex.Strings'spam', "Bob's", b'a\x01c', u'sp\xc4m...
Hello, World! is the first basic program in any programming language.Python Version
Print the Python version number and exit. Example output could be:
Python version
python -V
python --version
Python 3.9.1
Running Files with Command Lines
You c...