Python添加<?xml version="1.0" encoding="UTF-8"?>
时间: 2023-06-03 08:04:44 浏览: 132
动态网页程序设计代码等 <?xml version="1.0" encoding="utf-8" ?>
您可以使用以下代码来在 Python 中添加 <?xml version="1.0" encoding="UTF-8"?>:
```python
with open('file.xml', 'w', encoding='utf-8') as f:
f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
# write other XML content below
```
阅读全文