您的位置:首页 > 编程语言 > Python开发

python的elementtree模块处理中文注意事项

2017-10-28 12:13 274 查看
原文地址:http://blog.csdn.net/yuanchao99/article/details/42010011

处理中文在进行写文件时,必须采用以下方式:

tree.write(nxmlpath, "UTF-8")

如果写成:tree.write(nxmlpath, "utf-8"),则会使输出文件缺少<?xml version="1.0" encoding="UTF-8"?>头

如果写成:<?xml version="1.0" encoding="utf8"?>,则输出文件的中文不能被正常编码。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: