我正在通过Alex Pale的django 1.8的最小django文件上传示例 -
我知道如何在表单中获取文件扩展名,但我怎样才能在视图中看到它。我知道我可以通过 -
访问该文件<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="navbar">
<a id="nav-toggle"><span></span></a>
<ul>
<li id="li1"><a href="3d.html">3d printing</a>
<ul>
<div class="dd1">
<li><a href="#">blueprints</a>
<ul>
<li style="border-radius: 0px 10px 10px 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla erat purus, hendrerit eget mi sit amet, tempus auctor arcu. Duis vehicula nunc et lectus maximus facilisis. In elementum hendrerit cursus. Morbi egestas at justo sed dictum. Suspendisse sed tortor nec ligula tristique pellentesque. Donec facilisis luctus quam, eu luctus leo. In in feugiat arcu. Pellen\</li>
</ul>
</li>
<li><a href="#">information</a>
<ul>
<li style="border-radius: 0px 10px 10px 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla erat purus, hendrerit eget mi sit amet, tempus auctor arcu. Duis vehicula nunc et lectus maximus facilisis.</li>
</ul>
</li>
<li class="noTransition"><a href="#">Software</a>
<ul>
<li style="border-radius: 0px 10px 10px 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla erat purus, hendrerit eget mi sit amet, tempus auctor arcu. Duis vehicula nunc et lectus maximus facilisis. In elementum hendrerit cursus. Morbi egestas at justo sed dictum. Suspendisse sed tortor nec ligula tristique pellentesque. Donec facilisis luctus quam, eu luctus leo. In in feugiat arcu. </li>
</ul>
</li>
</div>
</ul>
</li>
<li id="li2"><a href="#">computing</a>
<ul>
<div class="dd2">
<li><a href="#">hardware</a>
<ul>
<li style="border-radius: 0px 10px 10px 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla erat purus, hendrerit eget mi sit amet, tempus auctor arcu. Duis vehicula nunc et lectus maximus facilisis. In elementum hendrerit cursus. Morbi egestas at justo sed dictum. Suspendisse sed tortor nec ligula tristique pellentesque. Donec facilisis luctus quam, eu luctus leo. In in feugiat arcu.</li>
</ul>
</li>
<li><a href="#">information</a>
<ul>
<li style="border-radius: 0px 10px 10px 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla erat purus, hendrerit eget mi sit amet, tempus auctor arcu. Duis vehicula nunc et lectus maximus facilisis.</li>
</ul>
</li>
<li class="noTransition"><a href="#">software</a>
<ul>
<li style="border-radius: 0px 10px 10px 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla erat purus, hendrerit eget mi sit amet, tempus auctor arcu. Duis vehicula nunc et lectus maximus facilisis. In elementum hendrerit cursus. Morbi egestas at justo sed dictum. Suspendisse sed tortor nec ligula tristique pellentesque. Donec facilisis luctus quam, eu luctus leo. In in feugiat arcu. </li>
</ul>
</li>
</div>
</ul>
</li>
<li><a href="#">virtual</a></li>
</ul>
</div>
查看 -
import numpy as np
image = read_image("YOUR_IMAGE") # need a rescale to be more realistic
noisy = np.random.poisson(image / 255.0 * PEAK) / PEAK * 255 # noisy image
表格 -
import numpy as np
image = read_image("YOUR_IMAGE")
noisemap = create_noisemap()
noisy = image + np.random.poisson(noisemap)
答案 0 :(得分:1)
如果您要求分机,请尝试:
>>> f = "this.that.ext"
>>> e = f.split(".")[-1]
>>> f
'this.that.ext'
>>> e
'ext'
>>>
您知道如何获取完整的文件名。你想要的是&#34;。&#34;
之后的最后一个字符串