python 利用views()和urls()生成四行随机数在浏览器上实现
答案:2 悬赏:0 手机版
解决时间 2021-02-21 12:02
- 提问者网友:鐵馬踏冰河
- 2021-02-20 13:01
使用dajngo。。。有两个文件urls()和views()生成四行随机数,然后在网页上输入127.0.0.1:8000查看结果
最佳答案
- 五星知识达人网友:蕴藏春秋
- 2021-02-20 13:14
这是做实验么....
urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
import views
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'test_site.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^$', views.test),
)
views.py:
from django.http import HttpResponse
import random
def test(request):
data = [str(random.random()) for e in range(4)]
html = '
'.join(data)
return HttpResponse(html)
urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
import views
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'test_site.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^$', views.test),
)
views.py:
from django.http import HttpResponse
import random
def test(request):
data = [str(random.random()) for e in range(4)]
html = '
'.join(data)
return HttpResponse(html)
全部回答
- 1楼网友:持酒劝斜阳
- 2021-02-20 13:43
没看懂什么意思?
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯