Created
January 14, 2019 02:53
-
-
Save ncole458/4f40704b41c595516d17fc8fbda79475 to your computer and use it in GitHub Desktop.
Python Encode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test .encode() and str() | |
a_string = 'test éurope' | |
print('a_string normal: ', a_string) | |
a_string = 'test éurope' | |
print('a_string utf-8 encoded: ', a_string.encode('utf-8')) # utf-8 is default so .encode() is same result | |
print('a_string ascii encoded: ', a_string.encode('ascii', 'replace')) # with error, i.e. replace, ignore etc. | |
print('a_string str: ', str(a_string)) | |
company = 'éuropean company' | |
pro_comp_name = 'a løng campaigné name' | |
report_name = company + " - " + pro_comp_name + ".pdf" | |
print('report_name: ', report_name) | |
print(f'report_name: {report_name}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment