Django抛出404并且无法正确匹配URL

时间:2015-02-04 06:08:57

标签: django url

这是链接指向的网址:

http://127.0.0.1/define/91/915/ans/%20%20%20%20%20%20%20%20%20%20%3Cp%3E%20Figure&nbsp;%3Ca%20href=%22node16.html#fig:bandits-graphs">   2.1</a> compares a greedy method with two <img width="13" height="16" align="BOTTOM" border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/img2.png" alt="$\varepsilon $">-greedy methods (<img border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/inimgtmp113.png" width="57" height="11"> and <img border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/inimgtmp114.png" width="49" height="11">), as described above, on the 10-armed testbed.  Both methods formed their action-value estimates using the sample-average technique. The upper graph shows the increase in expected reward with experience.  The greedy method improved slightly faster than the other methods at the very beginning, but then leveled off at a lower level.  It achieved a reward per step of only about 1, compared with the best possible of about 1.55 on this testbed.  The greedy method performs significantly <span class="highlight-wrapper"><span class="highlight" data-id="idtobesetinview"><span class="html">texthtmlgoeshere</span></span>worse<span id="noblankspace"></span></span> in the long run because it often gets stuck performing suboptimal actions.  The lower graph shows that the greedy method found the optimal action in only approximately one-third of the tasks.  In the other two-thirds,  its initial samples of the optimal action were disappointing, and it never returned to it.  The <img width="13" height="16" align="BOTTOM" border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/img2.png" alt="$\varepsilon $">-greedy methods eventually perform better because they continue to explore, and to improve their chances of recognizing the optimal action.  The <img border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/inimgtmp115.png" width="49" height="11"> method explores more, and usually finds the optimal action earlier, but never selects it more than 91% of the time.  The <img border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/inimgtmp116.png" width="57" height="11"> method improves more slowly, but eventually performs better than the <img border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/inimgtmp117.png" width="49" height="11"> method on both performance measures.  It is also possible to reduce <img width="13" height="16" align="BOTTOM" border="0" src="https://webdocs.cs.ualberta.ca/~sutton/book/ebook/img2.png" alt="$\varepsilon $"> over time to try to get the best of both high and low values.  </p><p></p>        /quabl/worse/cques/Worsexqmx/highlight/worse

但是Django会抛出404而只接受前几个字符:

http://127.0.0.1/define/91/915/ans/%20%20%20%20%20%20%20%20%20%20%3Cp%3E%20Figure&nbsp;%3Ca%20href=%22node16.html

网址绑定是:

    url(r'^define/(?P<post_id>\w+)/(?P<simpler_id>\w+)/ans/(?P<answer_part>[\w|\W]+)/quabl/(?P<quabl>[\w|\W]*)/cques/(?P<cques>[\w|\W]*)/highlight/(?P<highlightx>[\w|\W]*)/$', define),

下一个角色是&#39;#&#39;。这是编码问题吗?如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

你正在使用\ w代表&#34;字符&#34;并且匹配所有内容。如果您想要创建一个能够匹配所有字符的正则表达式,那么您需要使用.*之类的字符(请查看此答案https://stackoverflow.com/a/11384464/119071

现在,我必须注意到我不太喜欢你如何指定你的网址模式。如果我算正确,你定义了6个(6个!)url参数,它们可以获得任何值!我没有这样做,我建议只在URL中添加所需的部分(可能只有post_idsimpler_id),所有其他参数都应该通过查询传递(正确编码)(如{{1} }})