• python 日记 day1


    1.python2 与 python3 的区别:
       a. python2 源码不标准,混乱,重复代码太多。默认方式是ascii码,解决方式:#-*- encoding:utf-8 -*-
       b. python3 统一 标准,去除重复代码。默认方式是utf-8
    2.python  的特点及定位是“优雅”、“明确”、“简单”。python 开发效率高,有非常强大的第三方库,具有可移植
    性,可扩展性,可嵌入性。代码不能加密,因为python是解释性语言,它的源码都是以名文形式存放的。
    3.编译型:一次性将所有程序编译成二进制文件
        缺点:开发效率低,不能跨平台。
        优点:运行速度快。  例如:c,c++,go
       解释型:当程序运行时,一行一行的解释
        优点:开发效率高,可以跨平台。有良好的兼容性,在任何环境下都可以运行,前提是安装虚拟机。
        缺点:运行速度慢,每次运行都要解释一遍。  例如:python ,php,ruby。
        java , c# 属于混合
    4.重点:python 是一门动态解释性的强类型定义语言
    5.变量:以数字,字母,下划线任意组成,不能以数字开头
       常量:全部为大写字母。
    6.基础数据类型:
       数字:int 1,2,3,4,5   数的取值范围: -2**63~2**63-1
       运算符:+ - * / ** %
       ps:type()  用以判断是数字还是字符串。例: print(True,type(True))
       字符串:str  可相加 可相乘 str * int.python 中用引号引起来的都是字符串。
    7.打印多行举例:

        msg='''hello

         hello

         hello'''

    1   age = int(input('输入你的年龄:',))
    2 if age < 18:
    3     print('你太小了才'+str(age)+'')
    4 elif age < 30:
    5     print('哇塞你都' + str(age) + '')
    6 else:
    7     print('你终年' + str(age) + '')''
     
    2.
    count = 1
    sum = 0
    while count <= 100:
        sum += count
        count +=1
    print(sumi)
    
    
    age = int(input('输入你的年龄:',))
    if age < 18:
    print('你太小了才'+str(age)+'')
    elif age < 30:
        print('哇塞你都' + str(age) + '')
    else:
        print('你终年' + str(age) + '')'''
    count = 0
    while count  < 10:
            count +=1
        if count == 7
    
    
    continue
    
        print(count
     
     
    count =1
    sum =0
    while count <=100:
        sum +=count
        count +=1
    print(count)
    count = 0
    while count < 100:
        count +=1
        if count % 2 == 1:
            print(count, end=" ")
    count = 0
    while count < 100:
        count += 1
        if count % 2 == 0:
            print(count, end=" ")
    count = 1
    sum = 0
    while count < 100:
    
        if count % 2 == 0:
            sum = sum - count
        else:
            sum = sum + count
        count += 1
    print(sum)
    i=0
    while i < 3:
        username = input("输入用户名:")
        password = input("输入密码:")
        if username == "**" and password == 123:
            print("登陆成功")
        else:
            print("登陆失败")
        i +=1
     
  • 相关阅读:
    pgrep 查询进程的工具
    shell脚本中>/dev/null的含义
    一条命令批量替换多个文件中字符串
    Centos 6.4上面用Shell脚本一键安装vsftpd
    centos 卸载vsftpd方法
    Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
    SHELL学习笔记----IF条件判断,判断条件
    CentOS挂载新硬盘
    Linux fdisk 命令
    Linux df 命令
  • 原文地址:https://www.cnblogs.com/lianggege123/p/8044030.html
Copyright © 2020-2023  润新知