简体   繁体   English

Python脚本如何通过HTML中的用户交互获取参数?

[英]How does a Python script get the parameters by user interaction in HTML?

I wrote a Python script that was used to predict the players on the court for a basketball game.我编写了一个 Python 脚本,用于预测篮球比赛场上的球员。 I used the Flask framework to generate an HTML page for presenting my results.我使用 Flask 框架生成 HTML 页面来展示我的结果。 My Python script requires some parameters to be entered, and if I were in Python, I would use the input function.我的 Python 脚本需要输入一些参数,如果我在 Python 中,我会使用输入 function。 However, I want these parameters to be entered by the users in the web page.但是,我希望用户在 web 页面中输入这些参数。 For this reason, I have spent 2 weeks learning HTML, CSS and JS, but I am still confused about the overall architecture of this project:为此,我花了 2 周时间学习 HTML、CSS 和 JS,但我仍然对这个项目的整体架构感到困惑:

How does a Python script get the parameters by users interaction in HTML? Python 脚本如何通过 HTML 中的用户交互获取参数? What do I need to learn next so that I can finish this project?接下来我需要学习什么才能完成这个项目?

Thank you very much.非常感谢。

There are a lot of ways to get user input from a web application.有很多方法可以从 web 应用程序获取用户输入。 It can be from a form, the url path, query string parameters, json in the body of a request, the headers, cookies, and more.它可以来自表单、url 路径、查询字符串参数、请求正文中的 json、标头、cookies 等。

Since you spent two weeks learning html, css, and js.由于您花了两周时间学习 html、css 和 js。 You don't mind learning.你不介意学习。 I would suggest taking some time to go through this tutorial.我建议通过本教程花一些时间来了解 go。 It will give you the tools you need to answer your question and a lot more.它将为您提供回答问题所需的工具等等。

https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world

Chapter 3 on web forms will probably be one you want to pay the most attention too.关于 web forms 的第 3 章可能也是您最需要关注的一章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM