2
저는 파이썬 기초를 연구하고 있습니다. 나는 그런 문제가있어, 나는 그것을 알아낼 수 없다.장고/파이썬 "다중 반복"
views.py
# -*- coding: utf-8 -*-
from django.http import HttpResponse
import datetime
def hello(request):
return HttpResponse("Hello, World!")
def time(request):
now = datetime.datetime.now()
html = "<html><body>Teraz jest %s</body></html>" %now
return HttpResponse(html)
def time_offset(request, offset):
delta = int(offset)
dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
assert False
shtml = "<html><body>za %s godzin będzie %s</body></html>" % (delta,dt)
return HttpResponse(shtml)
urls.py는
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^hello$', 'mysite.views.hello', name='hello'),
url(r'^time$', 'mysite.views.time', name='time'),
url(r'^time\plus\(/d+{1,2})$', 'mysite.views.time_offset', name='time_offset'), )
그것은 모든 마지막 줄 내가 URL에 대한합니다. 나는 새로운 시각 "time_offset"을 활성화하고 있는데, 틀린 것이 틀림 없다. 그러나 khnow는 무엇을하고 있나? 나는이 견해를 작동시킬 수 없다.
도움을 주셔서 감사합니다.
오류 코드 :
는error at /time/plus/2
multiple repeat
Request Method: GET
Request URL: http://127.0.0.1:8000/time/plus/2
Django Version: 1.4.5
Exception Type: error
Exception Value:
multiple repeat
Exception Location: /usr/lib/python2.7/re.py in _compile, line 242
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home/maze/Dokumenty/djcode/mysite',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7']
Server time: Tue, 10 Dec 2013 04:40:17 -0600
그 것이다. 바로 답변 주셔서 감사합니다! – user3087161