34、输出保存txt
<pre><code># 在windows 命令行会有gbk错误,在ubuntu命令行可以正确运行 输出到text.txt
zcr@acer:/mnt/e/work/practice$ python3 to_text.py > text.txt
zcr@acer:/mnt/e/work/practice$ python3 to_text.py > text2.txt
zcr@acer:/mnt/e/work/practice$ python3 to_text.py > text3.txt
zcr@acer:/mnt/e/work/practice$ python3 to_text.py > text4.txt
zcr@acer:/mnt/e/work/practice$ python3 to_text.py > text5.txt
zcr@acer:/mnt/e/work/practice$
# cat qq.json | python prepare_file.py > qq1.json
# 读取qq.json做为输入 经过 prepare_file 中的操作,所有的print输出做为qq1.json中的文件
import pickle
class PdfName():
def __init__(self,name,url):
self.name = name
self.url = url
def get_name(self):
return self.name
def get_url(self):
return self.url
pdf_object_list = pickle.load(open('./pdf_object_list_2.txt', 'rb'))
for item in pdf_object_list:
if isinstance(item,str):
print("\n******************************************************")
print(item)
print("******************************************************")
continue
print(item.get_name())
print(item.get_url())
</code></pre>