zoukankan      html  css  js  c++  java
  • python_day02 上节课知识点回顾

    上节课知识点回顾:

    1、python3和python2多版本共存问题

    注:需要复制python36和python27目录下的python.exe后重命名,复制scripts下的pip.exe后重命名

    2、变量var

    注:变量三特性:id/type/value

    变量和值之间是绑定关系

    ??值是在内存中开辟了一块空间,变量存储在什么地方后面会讲到。

    name='liwj'
    print(id(name),type(name),name)

    38773400 <class 'str'> liwj

    3、python3和python2用户交互用法差异

    python3 input()输入内容全部为str类型

    python2 raw_inpput()输入内容全部为str类型==python3中的input()

    python2 input()输入内容什么类型输出就是什么类型,int/list/dict

    4、eval()

    eval() 是将字符串里面的内容读出来,执行一遍

    res='[1,2,3]'
    print(type(res)) #str
    print(type(eval(res))) #list
    res='1,2,3'
    print(type(res)) #str
    print(eval(res))
    print(type(eval(res))) #tuple元组
    res='{1,2,3}'
    print(type(res)) #str
    print(eval(res))
    print(type(eval(res))) #set集合

    5、python格式一定要有缩进,4个空格。

    6、while+else用法:else代码只要没有break就会执行

    7、python3和python2长整型区别:

    python2中

    8、复数

    x=1-2j
    print(x.real)
    print(x.imag)
    1.0
    -2.0
  • 相关阅读:
    POJ 3672 水题......
    POJ 3279 枚举?
    STL
    241. Different Ways to Add Parentheses
    282. Expression Add Operators
    169. Majority Element
    Weekly Contest 121
    927. Three Equal Parts
    910. Smallest Range II
    921. Minimum Add to Make Parentheses Valid
  • 原文地址:https://www.cnblogs.com/liweijing/p/7144378.html
Copyright © 2011-2022 走看看