标签:python 一日一练 django 网络编程 正则表达式
#coding:utf-8 from django.shortcuts import render from django.http import HttpResponse,Http404 # Create your views here. def num_plus(request,plus): try: plus=int(plus) except ValueError: raise Http404() sum=0 for x in range(plus+1): sum+=x html="<html><body><p>最终结果为%d</p></body></html>" % sum return HttpResponse(html)urls.py文件
from django.conf.urls import patterns, include, url from django.contrib import admin urlpatterns = patterns('', # Examples: # url(r'^$', 'mysite.views.home', name='home'), #url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), url(r"^sum/(\d+)/$","timer.views.num_plus") )
Python一日一练104----Django URLconf练习
标签:python 一日一练 django 网络编程 正则表达式
原文地址:http://blog.csdn.net/a359680405/article/details/43192807