环境
- ubuntu
- pycharm community 2019.3
- python 3.8
Python笔记
查看python库地址
/$ python3.8
>>> import sys
>>> sys.path
缩进问题
IndentationError: unexpected indent
字典输出
转化为字符串
中文是字符串形式
import json
json.dumps()
卡在了字典写入txt文件,字符串输出中文是编码
输出 .txt 文件
使用下面的代码后,txt文件中的中文成功输出
#得到图片中文字的行数
num = res['words_result_num']
#将列表中'words_result'所报包含的内容提取出来,num个字典
word = res['words_result']
#将识别出来的文字文本保存到"识别文本.txt"中
def resq():
for i in range(0,num):
dic = word[i]
with open('result.txt', "a+", encoding="utf-8") as f:
f.write(dic['words'])
if __name__ == '__main__':
resq()