Decoding Email Header and Contents
Using email.parser
and email.policy
along with policy.default
means that
you do not need to worry about character encoding as the modules will take care
of it automatically.
I forget where I saw it but I believe that policy.default will become the real
default in the future.
Current policy.compat32
is the module default.
Different String Padding Approaches
Padding Numbers
>>> n = 4
>>> print(f'{n:03}') # Preferred method, python >= 3.6
004
>>> print('%03d' % n)
004
>>> print(format(n, '03')) # python >= 2.6
004
>>> print('{0:03d}'.format(n)) # python >= 2.6 + python 3
004
>>> print('{foo:03d}'.format(foo=n)) # python >= 2.6 + python 3
004
>>> print('{:03d}'.format(n)) # python >= 2.7 + python3
004
Reference: Stack Overflow
Generate QR Codes
I want to try and do something with this eventually. Looks very useful.
Required imports:
pip install pillow
pip install qrcode
Code Sample:
import qrcode
# Link for website
input_data = "https://towardsdatascience.com/face-detection-in-10-lines-for-beginners-1787aa1d9127"
# Creating an instance of qrcode
qr = qrcode.QRCode(
version=1,
box_size=10,
border=5)
qr.add_data(input_data)
qr.make(fit=True)
img = qr.make_image(fill='black', back_color='white')
img.save('qrcode001.png')
Mock Python version for Testing
Google API Gmail LINE Notifications Part 7
Final part in a series of articles on implementing a notification system using Gmail and Line Bot.
[Read More]Google API Gmail LINE Notifications Part 6
Part 6 in a series of articles on implementing a notification system using Gmail and Line Bot.
[Read More]Google API Gmail LINE Notifications Part 5
Part 5 in a series of articles on implementing a notification system using Gmail and Line Bot.
[Read More]Google API Gmail LINE Notifications Part 4
Part 4 in a series of articles on implementing a notification system using Gmail and Line Bot.
[Read More]Google API Gmail LINE Notifications Part 3
Part 3 in a series of articles on implementing a notification system using Gmail and Line Bot.
[Read More]