我有一个像这样的字符串:
receiving incremental file list genelaytics/ genelaytics/.project 421 3% 411.13kB/s 0:00:00 421 3% 411.13kB/s 0:00:00 (xfr#1, to-chk=13/15) 421 3% 411.13kB/s 0:00:00 (xfr#1, to-chk=8/15) genelaytics/.pydevproject 1,006 7% 982.42kB/s 0:00:00 (xfr#2, to-chk=12/15) genelaytics/hello.py 1,006 7% 982.42kB/s 0:00:00 (xfr#3, to-chk=11/15) genelaytics/manage.py 1,260 10% 1.20MB/s 0:00:00 (xfr#4, to-chk=10/15) genelaytics/ok.py 1,260 10% 1.20MB/s 0:00:00 (xfr#5, to-chk=9/15) genelaytics/genelaytics/ genelaytics/genelaytics/__init__.py 1,260 10% 35.16kB/s 0:00:00 (xfr#6, to-chk=7/15) genelaytics/genelaytics/__init__.pyc 1,399 11% 39.03kB/s 0:00:00 (xfr#7, to-chk=6/15) genelaytics/genelaytics/settings.py 6,416 50% 179.02kB/s 0:00:00 (xfr#8, to-chk=5/15) genelaytics/genelaytics/settings.pyc 9,468 75% 264.17kB/s 0:00:00 (xfr#9, to-chk=4/15) …
我有一个像这样的html模板:
<table border="1" align="center">
{% for result in result %}
<tr>
<td><input type="checkbox" name="choice" id="choice{{ forloop.counter }}" value="{{ choice }}" /></td>
<td><label for="choice{{ forloop.counter }}">{{ choice }}</label><br /></td>
<td>{{ result.file_name }}</td>
<td>{{ result.type }}</td>
<td>{{ result.size }}</td>
<td>{{ result.end_date }}</td>
<td>{{ result.source }}</td>
{% endfor %}
</tr>
</table>
{{ c }}
<h4><a href="/delete_files/">Delete File</a></h4>
Run Code Online (Sandbox Code Playgroud)
result variable 由以下内容生成:
def uploaded_files(request):
log_id = request.user.id
b = File.objects.filter(users_id=log_id, flag='F') #Get the user id from session .delete() to use delete
return render_to_response('upload.html', {'result': b}, …Run Code Online (Sandbox Code Playgroud) 我有一个查看报告的功能:
def view_report(request):
a = Bill.objects.all()
return render_to_response('report.html', {'a':a}, context_instance=RequestContext(request))
Run Code Online (Sandbox Code Playgroud)
有一个名为price的属性,它有数字元素.我想总结所有价格并在Django模板中显示为一个数字:
{% for i in a %}
{{ i.price }}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
这只是返回所有价格.我想总结所有这些价格,并显示为一个.我尝试使用{{ i.price|sum }}哪个不起作用.
我想在守护进程模式下运行Django开发服务器,这样当我退出shell时,服务器仍然会运行.我怎样才能做到这一点?
我有一个这样的列表:
la = [3, 7, 8, 9, 50, 100]
Run Code Online (Sandbox Code Playgroud)
我试图将列表转换为字符串并添加如下百分比:
3%, 7%, 8% and lastly 100%
Run Code Online (Sandbox Code Playgroud)
我这样做:
str1 = '%, '.join(str(e) for e in sorted_list)
Run Code Online (Sandbox Code Playgroud)
这是正确的,除了最后没有百分比,即只有100,但我想要100%.我怎样才能做到这一点?谢谢
我有两个清单:
a = ['a', 'b', 'c']
b = [1]
Run Code Online (Sandbox Code Playgroud)
我希望我的输出为:
a, 1
b, 1
c, 1
Run Code Online (Sandbox Code Playgroud)
试过这样做:
for i, j in zip(a, b):
print i, j
Run Code Online (Sandbox Code Playgroud)
我只得到a, 1.我怎么能做对的?
这是我的实际情况:
if request.POST.get('share'):
choices = request.POST.getlist('choice')
person = request.POST.getlist('select')
person = ''.join(person)
person1 = User.objects.filter(username=person)
for i, j in izip_longest(choices, person1, fillvalue=person1[-1]):
start_date = datetime.datetime.utcnow().replace(tzinfo=utc)
a = Share(users_id=log_id, files_id=i, shared_user_id=j.id, shared_date=start_date)
a.save()
return HttpResponseRedirect('/uploaded_files/')
Run Code Online (Sandbox Code Playgroud) 例如,如果我有这样的字符串:
a = "username@102.1.1.2:/home/hello/there"
Run Code Online (Sandbox Code Playgroud)
如何删除最后一个单词后的最后一个单词/.结果应该是这样的:
username@102.1.1.2:/home/hello/
OR
username@102.1.1.2:/home/hello
Run Code Online (Sandbox Code Playgroud)