python 批量查询网页导出结果_python数据库批量查询,批量保存

时间:2024-10-05 07:08:09

# Create your views here.

#-*-coding:utf-8-*-

from django.template import loader,Context,Template

from import HttpResponse

from models import User

from import render_to_response

def index(req):

#批量查询出数据

startId =1

endId=100

numId = (endId-startId)+1

numi=numId/20

addnumId= numId%20

for i in range(numi):

Idstart=startId

Idend=i*20

user =(pk__gt=0).filter(pk__lt=5)

print ()

if len(user)>0:

print 'fff'

else:

print 'kong'

#print user

data1 =[]

data=[]

for key in user:

()

()

()

# print data1

(data1)

data1=[]

#批量保存

# for user in range data :

# user =user

#data=[['李四',12,'女'],['王五',56,'男'],['赵六',25,'男']]

stu=User()

for user in data:

print user

#(name=user[0],age=user[1],sex=user[2])

#(user)

# ()

#print data

return render_to_response('',{''})

def instance(startId,endId):

#startId =1

#endId=100

numId= (endId-startId)+1

numi=numId/20

addnumId=numId%20

if addnumId >0:

numi+=1

for i in range(numi):

if i==0:

Idstart=startId

Idend =(i+1)*20+startId

print Idstart,Idend

elif i==(numi-1):

Idstart=startId+(i*20)

Idend =endId

print Idstart,Idend

else:

Idstart=startId+(i*20)

Idend =(i+1)*20+startId

print Idstart,Idend