Python小知识

1_    python是一种解释性语言,当程序运行时,一行一行的解释,并运行;优点--调试代码很方便,开发效率高,并且可以跨平台;不但入门容易,而且将来深入下去,可以编写那些非常非常复杂的程序。缺点--运行速度慢。  python的种类:CPython   IPython   PyPy    Jython   IronPython

 

2_    变量:1.数字,字母,下划线的任意组合,但是不能以数字开头。

      2.不能是Python中的关键字,不要用中文,不要用拼音。

        3.驼峰法、下划线

 

3_    基本数据类型:1数值型(int)   2字符串型(str)     3布尔型(bool)


字符串的拼接可以进行加法和乘法,

 


4_    if语句

 if 条件:

         语句

       while循环

 while 条件:  

   语句

如何跳出while循环:改变条件,跳出循环。

num = 0
flag=True

while flag:
    num +=1
    print(num)
    if num==100:
        flag=False



name = input("请输入你的姓名:")
age = input("请输入你的年龄:")
job = input("请输入你的职业:")
hobby = input("请输入你的爱好:")
msg='''
------------ info of %s -----------
Name  : %s
Age   : %s
job   : %s
Hobbie: %s
------------- end -----------------
'''%(name,name,age,job,hobby)

print(msg)

  

from django.shortcuts import render,redirect,HttpResponse

# Create your views here.


def login(request): if request.method == "POST": username = request.POST.get("username") password = request.POST.get("password") if username == "zhuyu" and password == "123456": return redirect("http://www.baidu.com/") else: return HttpResponse("用户密码错误") return render(request,"login.html")

  

posted @ 2019-05-24 21:41  HelloBaby!  阅读(198)  评论(0)    收藏  举报