Python将txt文件转换为pd

2024-10-01 13:32:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道什么是最简单的方法转换txt文件在路径批转换为PDF?在

我已经在Python中研究过了https://github.com/baruchel/txt2pdf 但导入后我似乎无法在终端中调用txt2pdf。在

还有其他建议吗?在

比如:

text_file = open(filename, 'r')
i = 0
for item in text_file:
    i += 1
    f = open("c:\\workspace\\{0}.txt".format(i), 'w')
    txt2pdf convert (whatever goes here)
        if i == 7:
           break

也用ReportLab尝试过

^{pr2}$

Tags: 文件方法texthttps路径githubtxtcom
1条回答
网友
1楼 · 发布于 2024-10-01 13:32:04

不确定你是否已经找到了解决方案,只是在我搜索与你的问题相关的答案时碰巧看到了这个问题。在

如果您在终端,您可以按以下方式运行:

python txt2pdf.py yourfile.txt 
## Make sure the txt2pdf.py is at your working environment and also the .txt too

或者,如果您在jupyter笔记本中运行,请按以下方式运行:

^{pr2}$

谢谢。在

相关问题 更多 >