为什么这行不通:
with open('file.pdf', 'w') as outfile:
outfile.write("Hello")
代码工作正常,但无法打开 .pdf 文件。普通文本文件和 pdf 有什么区别?如果我想在 python 中创建和写入 pdf 文件怎么办?
原文由 user8471763 发布,翻译遵循 CC BY-SA 4.0 许可协议
为什么这行不通:
with open('file.pdf', 'w') as outfile:
outfile.write("Hello")
代码工作正常,但无法打开 .pdf 文件。普通文本文件和 pdf 有什么区别?如果我想在 python 中创建和写入 pdf 文件怎么办?
原文由 user8471763 发布,翻译遵循 CC BY-SA 4.0 许可协议
2 回答5.2k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
2 回答884 阅读✓ 已解决
1 回答1.8k 阅读✓ 已解决
您可以安装 fpdf 库,然后: