Python3输出到html写文件需注意,出现前缀b'
来源:互联网 发布:实时网速监控软件 编辑:程序博客网 时间:2024/05/22 06:19
def output_html(self): fout=open('output.html','w',encoding='UTF-8', newline='') fout.write('<html>') fout.write('<head>') fout.write('<meta charset = "UTF-8"/>') fout.write('</head>') fout.write('<body>') fout.write('<table>') for data in self.datas: fout.write('<tr>') fout.write('<td>%s</td>' % data['url']) fout.write('<td>%s</td>' % data['title']) fout.write('<td>%s</td>' % data['summary']) fout.write('</tr>') fout.write('</table>') fout.write('</body>') fout.write("</html>")
要注意open方法,还有指定网页的编码格式为utf-8,否则会出现字符串b前缀和编码错误
UnicodeEncodeError: 'gbk' codec can't encode character '\u02c8'
0 0
- Python3输出到html写文件需注意,出现前缀b'
- 用"blog_backup"导出的html文件,粘贴到CSDN注意
- 写头文件注意
- JAVA 如何将输出写到文件中
- python3.5之写文件
- 数字输出到文件出现乱码的情况
- Python3.6笔记之将程序运行结果输出到文件
- python3 如何转换html到pdf
- java类生成日历自己写的,可以输出到html页面
- python3.x输出文件最后几行
- 将html代码保存到xml文件中并用xsl转换输出到网页中的方法
- Java解析HTML到org.w3c.dom.Document,再把Document输出到文件。
- python3 以utf-8编码写文件
- PoEdu_Python_Lesson009_类的基础用法、使用dump写数据到json文件的注意点
- java文件输出流,写到.txt文件,如何实现换行
- 如何使用文件字节输出流(FileOutputStream)将数据写到磁盘文件中
- java 写一个"HelloJavaWorld你好世界"输出到操作系统文件Hello.txt文件中
- 如何使用文件字节输出流(FileOutputStream)将数据写到磁盘文件中
- 【千里码】文件管理
- VS2013+OpenCV3.0编译TLD跟踪算法
- C语言(自加自减)
- 使用CPACK制作安装包
- File Demo
- Python3输出到html写文件需注意,出现前缀b'
- JS中继承的几种用法
- A simple model for describing basic sources of possible performance problems
- 利用socket.io实现多人聊天室(基于Nodejs)
- tuple是固定的list
- 低功耗蓝牙4.0BLE编程-nrf51822开发(3)
- jquery ui widget原理解析
- 快速排序简单讲解
- ListView的异步加载图片问题与优化