【发布时间】:2020-06-24 03:11:15
【问题描述】:
views.py
def inp(request):
return render(request,'inp.html')
def tab(request):
num1 = dict()
number =int (request.GET.get('num'))
for i in range(1,11):
num1[i] = number*i
for key in num1:
print(num1[key])
return render(request,'tab.html',{"result" : num1[key]})
inp.html
<!DOCTYPE html>
<html>
<head>
<title>table</title>
</head>
<h1>Enter The Number Which You Want For Table</h1>
<body>
<form action ="tab/" method="get">
Enter a Number:<input type = "text" name ="num">
<input type = "submit">
</form>
</body>
</html>
tab.html
<!DOCTYPE html>
<html>
<head>
<title>output</title>
</head>
<body>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
your answer is {{result}}<br>
</body>
</html>`enter code here`
- List item
【问题讨论】:
-
请清晰描述您的问题。
-
因为在for循环中返回所以第一次返回程序将返回第一个值并停止执行。
-
任何选择
-
@TusharKhowal 你想打印乘法表吗?
-
@ShubhamDevgan 是的