• Python简介


    编译型语言:
    写好代码之后就把代码编译成二进制文件,运行的时候运行编译好的二进制文件;
    例如:c、 c++ 、 c#/
    优点:运行的速度快,一次编译,到处运行;
    缺点:编译过程比较慢;

    解释型语言:
    运行一行额代码编辑一行,什么时候运行代码,什么时候编译代码;
    例如:PHP、Python、ruby、Java、go、JavaScript
    缺点:运行速度比较慢;

    脚本语言:
    功能单一的语言叫脚本语言;
    例如:shell、bat、JavaScript、HTML、vb

    Python应用:后台服务开发、数据挖掘、数据分析、人工智能、自动化运维、自动化测试

    Python实现登录校验示例:

    import datetime
    today = datetime.date.today()
    username = 'wanghao'
    password = 123456
    password = str(password)
    print('账号是:'+username)
    print('密码是:'+password)
    count = 0
    while count < 3:
    username = input('请输入用户名:')
    password = input('请输入密码:')
    if username == 'wanghao' and password =='123456':
    login = '%s 欢迎登陆,今天的日期是:%s,程序结束 '%(username,today)
    print(login)
    break
    elif username.strip()=='' or password.strip()=='':
    print('账号/密码不能为空')
    elif username!='wanghao' or password!='123456':
    print('账号/密码输入错误')
    count+=1
    else:
    print('失败次数过多!!!')


    Python字符串格式化示例:
    # 字符串格式化
    import datetime

    today = datetime.date.today()
    username = input('请输入用户名:')
    # welcome = '欢迎光临:' + username # 第一种方式
    welcome = '欢迎光临:%s 今天的日期是:%s 今天下雨了!!!' % (username, today)
    # 用占位符 %s 字符串 %d 整数 %.2f 小数
    print(welcome)
    age = 18
    score = 99.994999
    info = '你的用户名是%s 年龄是%d 成绩是%.2f'%(username,age,score)
    print(info)

    Python while 循环猜数字游戏示例:
    #循环,重复的去做一件事情
    #循环、迭代、遍历都指的是循环
    #for循环,while循环
    #while循环必须要有一个计数器

    import random
    num = random.randint(1,100)
    count = 0 #计数器
    while count < 10:
    guess = input('请输入你要猜的数字:')
    guess = int(guess)
    if guess > num:
    print('数字猜大了')
    elif guess < num:
    print('数字猜小了')
    else:
    print('恭喜你猜对了,数字是:',num)
    break
    #break在循环里面遇到break,立马结束循环。
    # continue在循环里面遇到continue那么就结束本次循环
    # 继续进行下次循环
    # print('hello word')
    count = count + 1
    #count+=1
    #循环体,循环的时候是重复执行循环体里面的东西

    python多条件判断示例:
    # 多条件判断,if条件判断的必须要冒号:
    # score = input('请输入你的成绩')
    # score = int(score)
    # if score>90:
    # print('优秀')
    # elif score>=75 and score<90:
    # print('良好')
    # elif score>=60 and score<75:
    # print('及格')
    # else:
    # print('不及格')
  • 相关阅读:
    C# 自定义泛型类,并添加约束
    WPF DataGrid 的RowDetailsTemplate的使用
    jquery腾讯微博
    WPF DataGrid的LoadingRow事件
    WPF DataGrid自定义列DataGridTextColumn.ElementStyle和DataGridTemplateColumn.CellTemplate
    WPF DataGrid支持的列类型
    WPF DataGrid自动生成列
    WPF DataTemplateSelector的使用
    WPF数据模板的数据触发器的使用
    UVa 1601 || POJ 3523 The Morning after Halloween (BFS || 双向BFS && 降维 && 状压)
  • 原文地址:https://www.cnblogs.com/ymmz/p/8610423.html
Copyright © 2020-2023  润新知