Python学习笔记

来源:互联网 发布:程序员的简历怎么写 编辑:程序博客网 时间:2024/05/16 12:52

Python 笔记
一.数据类型
Python 3 中有六种数据类型
1.Number (数字)
2.Tuple (元组)
3.Dictionary(字典)
4.String (字符串)
5.List(列表)
6.Sets(集合)

1.Number(数字)
有三种不同的类型
(1)int
(2)float
(3) complex (复数)
备注: // 地板除 只取结果的整数部分

数据类型的转换

>>>int(345.5) >345>>> float(345.5)>345.5>>>float(int(345.5))>345.0

二、Python 运算符
成员运算符
in 在序列中找到值
not in 在序列中没有找到的值

>>> a=7>>> list=[8,5,5,0,4]>>> print(a in list)False

身份运算符
is 判断两个标识符是否引用自一个对象
is not 判断两个标识符是否引用自不同的对象

>>> a=18>>> b=26>>> print(a is not b)True

三、通用序列操作
1.索引

>>> Geeting='hello world'>>> Geeting[6]  ---从左到右 0 1 2 3 4 5 6 7 8 9 10'w'>>> Geeting[-6]  ---从右到左 -11 10 9 8 7 6 5 4 3 2 1' '
原创粉丝点击