Python的数据类型

1.学习目录:

  数字(整型、长整型,浮点型,复数)
  字符串
  列表

  元祖

  字典

  集合



2.学习目标:

  1.用途

  2.定义方式

  3.常用操作 and 内置的方法

  

一.  整形与浮点型

  整形 int : money = 6000  age = 22
  浮点 float: money = 5.2

  长整型(python3没有):
  >>> num = 2L
>>> type(num)
>>> <type 'long'

  复数:
  >>> num = 1 - 2j  
二. 字符串
     作用:描述、性别,地址等信息
     定义:定义在单引号 or 双引号  or 三引号内
     name = "tom"

     1.优先掌握的操作:
        1.按索引值取值(正向取OR反向取)
        2.切片
        3.长度  len
        4.成员运算 与 not in
        5.移除空白字符 strip
        6.切分split
        7.循环

     2.次要优先掌握:
        1.strip, lstrip, rstrip
        2.lower, upper
        3.startswith,endswith
        4.format 三种写法
        5.split, rsplit
        6.join
        7.replace
        8.isdigit


#strip
     name = "*abc**"
     name.strip("*")  
     name.lstrip("*") 
     name.rstrip("*")

猜你喜欢

转载自www.cnblogs.com/jbzd/p/9048660.html