• python3 入门


    python3 每日一练 正式开板 程序均在win7+python3.2.3 测试通过

    python3 下载地址:http://west263.newhua.com/down/python-3.2.3.zip

    Register Extensions:注册扩展名,允许双击编辑python脚本(.py)

    Tcl/Tk:Python Shell 图形化类库,必选

    Documentation:文档,帮助文件,可访问docs.python.org查看,可选

    Utility Scripts:实用脚本,其中包含python2移植到python3脚本,可选

    Test suite:测试套件,测试python解释器的脚本集合,可选

    设置windows环境变量:变量PATH 值set PATH="D:\python3.2.3\"

    临时生效,打开doc窗口,设置系统环境变量set PATH="D:\python3.2.3\"

    在命令含中输入python,进入python编译程序

    1 C:\>python
    2 Python 3.2.3 (default, Apr 11 2012, 07:15:24) [MSC v.1500 32 bit (Intel)] on win
    3 32
    4 Type "help", "copyright", "credits" or "license" for more information.
    5 >>>

    1、程序输出 print()

    1  >>> print("hello world")
    2 hello world

    2、程序输入 input()

    1 >>> input("输入你的姓名:")
    2 输入你的姓名:林振杰
    3 '林振杰'

    3、注释 使用"#"注释

    4、操作符

    标准算术操作符 比较操作符 逻辑操作符
    + < 小于 and
    - <= 小于等于 or
    * > 大于 not
    / >= 大于等于    
    // 整除 == 等于    
    % != 不等于    
    ** 乘方        

     

     

     

     

     

     

    5、数字

    有符号整型:短整型int,长整型long,布尔值bool

    浮点型float

    复数complex

    6、字符串  索引操作符号[],切片操作符[:],连接运算符+,重复运算符*

    1 >>> str="林振杰的博客"
    2 >>> str[2]
    3 ''
    4 >>> str[2:4]
    5 '杰的'
    6 >>> str+"Python入门"
    7 '林振杰的博客Python入门'
    8 >>> str*2
    9 '林振杰的博客林振杰的博客'

    7、列表:使用[]包裹,元素个数和值可以改变

     1 >>>word=['a','b','c','d','e','f','g']
     2 >>> c=word[2];
     3 >>> print("c is "+c)
     4 c is c
     5 >>> d=word[-4]
     6 >>> print("d is "+d)
     7 d
     8 >>> be=word[1:4]
     9 >>> print(be)
    10 ['b', 'c', 'd']
    11 >>> word[2]='d'
    12 >>> ag=word[:2]+word[2:]
    13 >>> print(ag)
    14 ['a', 'b', 'd', 'd', 'e', 'f', 'g']
    15 >>> l = len(word)
    16 >>> print(l)
    17 7

    8、元祖:使用()包裹,只读列表元素个数和值不可改变

    1 >>> word=('a','b','c','d','e','f','g')
    2 >>> c = word[2]
    3 >>> print("c is "+c)
    4 c is c

    9、字典

    1 >>> me={"name":"林振杰","age":23}
    2 >>> me["name"]
    3 '林振杰'
    4 >>> for key in me:
    5 ...     print(key,me[key])
    6 ...
    7 age 23
    8 name 林振杰

    10、条件

     1 >>> x=int(input("enter an integer:"))
     2 enter an integer:10
     3 >>> if x<0:
     4 ...     x=0
     5 ...     print("x < 0 ")
     6 ... elif x== 0:
     7 ...     print("x = 0")
     8 ... else:
     9 ...     print("x > 0")
    10 ...
    11 x > 0

    11、循环

     1 >>> word = ['a','b','c']
     2 >>> for x in word:
     3 ...     print(x)
     4 ...
     5 a
     6 b
     7 c

    12、函数

    13、异常处理

    14、文件处理

    15、类和继承

    16、包机制

    17、内建帮助手册

  • 相关阅读:
    POJ1064 浮点数二分答案
    2019牛客暑期多校训练营(第二场)H.Second Large Rectangle
    最大全1子矩阵的两种解法(例题:City Game HDU
    POJ
    Codeforces Round #588 (Div. 2) C
    1216E
    1221D
    BUY LOW, BUY LOWER, POJ
    Priest John's Busiest Day (2-sat)
    poj1080
  • 原文地址:https://www.cnblogs.com/linzhenjie/p/2635643.html
Copyright © 2020-2023  润新知