Message97335
| Author |
vstinner |
| Recipients |
grego87, nirai, vstinner |
| Date |
2010年01月07日.01:30:04 |
| SpamBayes Score |
8.446084e-05 |
| Marked as misclassified |
No |
| Message-id |
<1262827807.0.0.685299656327.issue7519@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Use utf_8_sig charset and open your file using io.open() or codecs.open() to get unicode sections, options and values.
Example:
-------------------------------------
from ConfigParser import ConfigParser
import io
# create an utf-8 .ini file with a BOM marker
with open('bla.ini', 'wb') as fp:
fp.write(u'[section]\ncl\xe9=value'.encode('utf_8_sig'))
# read the .ini file
config = ConfigParser()
with io.open('bla.ini', 'r', encoding='utf_8_sig') as fp:
config.readfp(fp)
# dump the config
for section in config.sections():
print "[", repr(section), "]"
for option in config.options(section):
value = config.get(section, option)
print "%r=%r" % (option, value)
------------------------------------- |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年01月07日 01:30:07 | vstinner | set | recipients:
+ vstinner, nirai, grego87 |
| 2010年01月07日 01:30:07 | vstinner | set | messageid: <1262827807.0.0.685299656327.issue7519@psf.upfronthosting.co.za> |
| 2010年01月07日 01:30:05 | vstinner | link | issue7519 messages |
| 2010年01月07日 01:30:04 | vstinner | create |
|