1.3 References 2 Python’s Unicode Support 2.1 The String Type 4 The errors argument specifies the response when the input string can’t be converted according to the encoding’s rules. Legal values for this argument are$_{'strict'}$ (raise a$_{UnicodeDecodeError}$ exception),$_{'replace'}$ (use$_{U+FFFD}$ ,$_{REPLACEMENT CHARACTER}$ ),$_{'ignore'}$ (just leave the character out of the Unicode result), or 'backslashreplace' (inserts a$_{\xNN}$ escape sequence). The following examples show the differences: In addition, one can create a string using the$_{decode()}$ method of$_{bytes}$. This method takes an encoding argu- ment, such as$_{UTF-8}$ , and optionally an errors argument. If you can’t enter a particular character in your editor or want to keep the source code ASCII-only for some reason, you can also use escape sequences in string literals. (Depending on your system, you may see the actual capital-delta glyph instead of a u escape.) Side note: Python 3 also supports using Unicode characters in identifiers: Since Python 3.0, the language’s$_{str}$type contains Unicode characters, meaning any string created using$_{"unicode}$ rocks!" ,$_{'unicode rocks!'}$ , or the triple-quoted string syntax is stored as Unicode. The default encoding for Python source code is UTF-8, so you can simply include a Unicode character in a string literal: Now that you’ve learned the rudiments of Unicode, we can look at Python’s Unicode features. Wikipedia entries are often helpful; see the entries for “character encoding” and UTF-8, for example. Another good introductory article was written by Joel Spolsky. If this introduction didn’t make things clear to you, you should try reading this alternate article before continuing. To help understand the standard, Jukka Korpela has written an introductory guide to reading the Unicode character tables. On the Computerphile Youtube channel, Tom Scott briefly discusses the history of Unicode and UTF-8 (9 minutes 36 seconds). The Unicode Consortium site has character charts, a glossary, and PDF versions of the Unicode specification. Be prepared for some difficult reading. A chronology of the origin and development of Unicode is also available on the site. try : with open('/tmp/input.txt ','r') as f: ... except OSError: # 'File not found' error message. print("Fichier non trouvé ") répertoire ="/tmp/records.log " with open(répertoire,"w") as f: f.write("test ") >>> " \N{GREEK CAPITAL LETTER DELTA} " # Using the character name '\u0394' >>> " \u0394 " # Using a 16-bit hex value '\u0394' >>> " \U00000394 " # Using a 32-bit hex value '\u0394'