简体   繁体   English

通过python脚本运行用户输入并在django站点上返回输出

[英]running user input through python script and returning output on django site

new python/django user here.新的 python/django 用户在这里。 i'm trying to set up a webpage that takes user input (eg, an address) into a form, then passes it through a python script (in a separate.py file) before returning an output to the same webpage (eg, the nearest traffic light).我正在尝试设置一个网页,该网页将用户输入(例如,地址)转换为表单,然后在将输出返回到同一网页(例如,最近的交通灯)。

how would i go about making the connection between my views.py file and my script.py file in django?我将如何在 Django 中建立我的 views.py 文件和我的 script.py 文件之间的连接?

simplified code: views.py file input = form.cleaned_data.get('enter_address')简化代码: views.py file input = form.cleaned_data.get('enter_address')

script.py file print(input) script.py 文件打印(输入)

you can use this to run python script你可以用它来运行 python 脚本

os.system("example.py 1")

or或者

import subprocess
subprocess.Popen("example.py 1", shell=True)

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

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