全部博文(2065)
分类: Python/Ruby
2009-08-14 16:47:12
sample_list = ['a',1,('a','b')]
sample_list = ['a','b',0,1,3]
value_start = sample_list[0]
end_value = sample_list[-1]
del sample_list[0]
sample_list[0:0] = ['sample value']
list_length = len(sample_list)
for element in sample_list:
print(element)
num_inc_list = range(30)
#will return a list [0,1,2,...,29]
initial_value = 0
list_length = 5
sample_list = [ initial_value for i in range(10)]
sample_list = [initial_value]*list_length
# sample_list ==[0,0,0,0,0]
以下是解决方案:
如果想要进行调试程序可以这样:
manage.py shell
在这里进行测试
from servermonitor.serverhardware.models import ServerHardware
obj = ServerHardware.objects.filter(h_serverserial='SB12-16-89')
print len(obj)
如果有记录则>0 如果没有记录就为0
就这样验证了!