Python
String format
Positioning
# "two one"
Padding
# " abc"
# "abc "
#
# "abc_______"
Numbers
# 003.14
Numbers format
Type | Meaning |
---|---|
b | Binary |
c | Unicode character |
d | Decimal |
e | Exponential notation (lowercase e ) |
E | Exponential notation (uppercase E ) |
f | Fixed point (lowercase inf and nan ) |
F | Fixed point (uppercase INF and NAN ) |
g | General (lowercase e ) |
G | General (uppercase E ) |
n | Same as d , but uses the number separator of locale settings |
o | Octal |
x | Hexadecimal (lowercase) |
X | Hexadecimal (uppercase) |
% | Percentage (multiply by 100 and puts % at the end) |
Download files
Download a file as a string:
return
Download a file:
=
, =
=
= .
=
=
Fix error: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate>
:
=
csv
Read a CSV file.
=
=
=
=
=
Write a CSV file.
=
=
virtualenv
Create a new environment (example: env
):
Or isolate the environment from the main package directory:
Now a folder (in this example, env
) has been created. This folder should contain subfolders bin
, include
, lib
. To enter the virtual environment:
# pip install ...
You can use pip
to install packages locally. In order to save the list of packages and their versions, you can use:
In a new environment, to install packages and the versions listed in requirements.txt
:
To exit the virtual environment: