0
您好,我想知道是否可以从公式中获取输入数据并将该数据用于其他函数?从公式获取输入数据并将其用作函数的参数
我forms.py:
我view.py:
def textpath(request):
success = False
text = ''
stopwords = ''
language = ''
search = ''
if request.method == 'POST':
textpath_form = TextPathForm(request.POST)
if textpath_form.is_valid():
success = True
text = textpath_form.cleaned_data['text']
stopwords = textpath_form.cleaned_data['stopwords']
language = textpath_form.cleaned_data['language']
search = textpath_form.cleaned_data['search']
else:
textpath_form = TextPathForm()
ctx = {'textpath_form':textpath_form,'text':text,'language':language,'stopwords':stopwords,'search':search,'succes': success,}
return render_to_response('index.html',ctx)
def any_function("need parameter text from textpath() "):
谢谢你帮助我。
如果我尝试: def any_function(textpath_form.cleaned_data):我得到一个SyntaxError。 或def any_function(x = textpath_form.cleaned_data): - > NameError text_path未定义 – SnowBallz 2011-03-09 09:23:35
不,不。执行'def any_function(data)',然后像'any_function(textpath_form.cleaned_data)'一样在你的请求中使用它。如果你想存储数据,所以你可以使用'any_function(textpath_form.cleaned_data)'外部请求,那么你需要将它存储在全局变量或数据库中。 – freakish 2011-03-09 12:55:31
啊,现在我明白了。谢谢。 – SnowBallz 2011-03-09 13:47:57