是否可以使用问题提示提示Python以特定格式输出整个文档?
Python是否有可能以特定格式输出整个文档?我是否可以通过问候/答案提示来完成此操作?这是我想要做的示例。
假设我想创建有关风暴分析的文档。我想启动一个“脚本”,python会问我一些问题,例如:
- 风暴名称是什么? (输入风暴名称,命中输入)
- 当前大约位置是什么? (输入风暴位置,命中输入)
- 当前压力是多少? (输入压力值,点击输入)
- 什么是风向摘要? (输入摘要,命中输入)
- 您有哪些风图? (输入PNG文件或类似的内容,请输入),
因此我希望它为完整的文档“向我询问”所有这些问题,然后以我想要的PDF或Word文档的格式输出。以下是较旧格式的示例(我可能不明确想要这个,但这只是一个通用的示例,我希望能够编程为Python):
Python可能会有这种类型的东西吗?还是最好留给另一个程序?
Is it possible for python to output whole documents with a specific format? And could I possibly have it do this by means of a question/answer prompt? Here's an example of what I would like it to do.
Let's say I wanted to create a document on storm analysis. I'd like to start a "script" where Python would ask me some questions such as:
- What is the storm name? (Enter storm name, hit enter)
- What is the current approximate location? (Enter storm location, hit enter)
- What is the current pressure? (Enter pressure value, hit enter)
- What is the wind direction summary? (Enter summary, hit enter)
- What images do you have for wind? (Enter png file, or something similar, hit enter)
So I would like it to do "ask" me all these questions for my complete document, then output it in a format that I want in say a pdf or word document. Here's an example of an older format (I may not explicitly want this, but this is just a generic example I'd hope to be able to program into Python):
Is this type of thing possible for python? Or is this better left to another program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样做的一种非常普遍的方法是使用诸如烧瓶/jinja之类的东西来创建HTML文档。从那里,您可以使用其他工具将页面转换为PDF/Image/任何内容。
使用类似的项目结构,
您可以编写以下内容来生成报告:
app.py:
template.html:
当您输入消息时,例如,将生成example.html中的html页面。这样:
因此,您可以使用它来自定义想要使用HTML/CSS和输入组合的任何报告。
One very common way of doing this is by using something like flask/jinja to create an html doc. From there you can convert the page to a pdf/image/whatever using other tools.
With a project structure like
You could write the following to generate a report:
app.py:
template.html:
When you type in a message, say "hi" for example, an html page in example.html will thus be generated that looks like this:
You could thus use this to customize whatever report you want using a combination of html/css and inputs.