Kaydet (Commit) a883701d authored tarafından Andrew M. Kuchling's avatar Andrew M. Kuchling

Provide encoding as keyword argument; soften warning paragraph about encodings

üst 4b4a63e3
...@@ -1724,14 +1724,15 @@ tree.write('output.xml') ...@@ -1724,14 +1724,15 @@ tree.write('output.xml')
# Encoding is UTF-8 # Encoding is UTF-8
f = open('output.xml', 'w') f = open('output.xml', 'w')
tree.write(f, 'utf-8') tree.write(f, encoding='utf-8')
\end{verbatim} \end{verbatim}
(Caution: the default encoding used for output is ASCII, which isn't (Caution: the default encoding used for output is ASCII. For general
very useful for general XML work, raising an exception if there are XML work, where an element's name may contain arbitrary Unicode
any characters with values greater than 127. You should always characters, ASCII isn't a very useful encoding because it will raise
specify a different encoding such as UTF-8 that can handle any Unicode an exception if an element's name contains any characters with values
character.) greater than 127. Therefore, it's best to specify a different
encoding such as UTF-8 that can handle any Unicode character.)
This section is only a partial description of the ElementTree interfaces. This section is only a partial description of the ElementTree interfaces.
Please read the package's official documentation for more details. Please read the package's official documentation for more details.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment