django中要指定时间做某件事的代码怎么弄?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django中要指定时间做某件事的代码怎么弄?相关的知识,希望对你有一定的参考价值。
参考技术A 在django项目中使用: python manage.py shell from django.db import connection #import 相关模型的class #执行query查询 print connection.queries 输入,ebyfcp追问不是这样的,就是一个服务,给它个时间,当今天跟指定时间对等的时候就自动去删除或者添加。。谢谢。。
流程控制之while循环
1.什么是循环
循环指的是一个重复做某件事的过程
2.为何要有循环
为了让计算机能够像人一样重复做某件事
3.如何用循环
#while循环的语法:while循环又称为条件循环,循环的次数取决于条件
while 条件
子代码1
子代码2
子代码3
....
print("start")
while True:
name = input("please your name>>")
pwd = input("please your password>>")
if name == "egon" and pwd == "123":
print("login successful")
else:
print("user or password err")
print("over")
#如何结束while循环
方式一:操作while循环的条件让其结束
print("start")
tag = True
while tag:
name = input(‘please your name>>:")
pwd = input("please your password>>")
if name == "egon" and pwd == "123":
print("login successful")
tag= False
else:
print("user or password err")
方式二:break强行终止本层循环
count=1
while count <6
print(count)
count+=1
count=1
while True:
while count <6
break
print(count)
count+=1
print("start")
while True:
name = input(‘please your name>>:")
pwd = input("please your password>>")
if name == "egon" and pwd == "123":
print("login successful")
break
else:
print("user or password err")
输错三次则退出
方式一.
print("start")
count = 0
while count <=2
name = input(‘please your name>>:")
pwd = input("please your password>>")
if name == "egon" and pwd == "123":
print("login successful")
break
else:
print("user or password err")
count+=1
print("end...")
方式二:
print("start")
count= 0
while True:
if count == 3:
print("输入错误次数过多")
break
name = input(‘please your name>>:")
pwd = input("please your password>>")
if name == "egon" and pwd == "123":
print("login successful")
break
else:
print("user or password err")
count+=1
print("end...")
#while+continue:continue代表结束本次循环,直接进入下一次
count = 1
if count == 4:
count +=1
continue #只能在cotinue同一级别之前加代码
print(count)
count+=1
重点:continue 不应该作为循环体最后一步执行的代码
#输错三次则退出之while+else的应用
print("start")
count =0
while count <=2:
name = input(‘please your name>>:")
pwd = input("please your password>>")
if name == "egon" and pwd == "123":
print("login successful")
break
else:
print("user or password err")
count +=1
else:
print("输入错误次数过多")
print("end...")
#while循环的嵌套
name_of_db ="egon"
pwd_of_db="123"
print("start")
count = 0
while count <=2:
name = input(‘please your name>>:")
pwd = input("please your password>>")
if name == "egon" and pwd == "123":
print("login successful")
while True:
print("""
1.浏览商品
2.添加购物车
3.支付
4.退出
""")
choice = input("请输入你的操作:")
if choice == "1":
print("浏览商品")
elif choice == "2":
print("正在添加购物车")
elif choice == "3"
print("正在支付")
elif choice == "4"
break
break
else:
print("user or password err")
count +=1
else:
print("输入错误次数过多")
print("end")
#tag控制所有的while循环
name_of_db=‘egon‘
pwd_of_db=‘123‘
tag=True
print(‘start....‘)
count=0
while tag:
if count == 3:
print(‘尝试次数过多‘)
break
name=input(‘please your name>>: ‘)
pwd=input(‘please your password>>: ‘)
if name == name_of_db and pwd == pwd_of_db:
print(‘login successful‘)
while tag:
print("""
1 浏览商品
2 添加购物车
3 支付
4 退出
""")
choice=input(‘请输入你的操作: ‘) #choice=‘1‘
if choice == ‘1‘:
print(‘开始浏览商品....‘)
elif choice == ‘2‘:
print(‘正在添加购物车....‘)
elif choice == ‘3‘:
print(‘正在支付....‘)
elif choice == ‘4‘:
tag=False
else:
print(‘user or password err‘)
count+=1
print(‘end...‘)
以上是关于django中要指定时间做某件事的代码怎么弄?的主要内容,如果未能解决你的问题,请参考以下文章