python1
##python##
#1.基本信息
#2.python 的安装
1)yum install python -y
2)ipython 的安装
3)pycharm的安装
#3.数据类型
#4.内置方法
#5.输入与输出
//实际效果
1.input接受数据类型数据:
2.raw_input接受字符串类型的数据:
3.三个学生的平均成绩
#6.判断语句:
1)if 和 else
if(表达式):
满足表达式执行的语句...
else:
不满足表达是执行的语句...
2)while循环
//break : 跳出循环,不再进行循环;
//coutinue:跳出本次循环,继续回到循环语句,执行下一次循环;
//exit(): 退出程序
#7.三目运算符
#8.字符串
1)索引
2)判断字符串
3)重复连接计算长度
4)字符串的常用操作
1.str.capitalize() ##将字符串首字母大写
2.str.center(width, fillchar) ##将str的字符放在width个fillchar中间
3.str.count(sub , start , end) ##返回sub在str中出现的次数
4.str.endswith(suffix , start , end) ##判断str是否以suffix结束
5.str.find(sub , start , end) ##判断sub是否再str中
6.str.index(sub , start , end) ##与find功能相同,再不存在时返回ValueError异常
7.判断字符
8.str.join(seq) ##在seq每个字符间加入str
9.str.replace(old , new , count) ##将old字符替换成new , count:只替换前count个字符中
10.str.split(sep , maxsplit) ##以sep为分隔符,对str切割
11.str.strip(chars) ##将str首位指定的chars字符删除,为指定,删除首位空格
#9.元组
1.定义元组
tuple = () ##空元组
tuple = (‘westos’ , ) ##单个值元组,元组由逗号决定,不由括号决定
tuple = (‘westos’ , ‘rendhat’) ##一般元组
2.元组的值不能任修改
3.对元组分别赋值,
4.元组的操作
索引,切片,重复,连接和查看长度
5.元组的方法
tuple.count(value) ##返回value再tuple中出现的次数
tuple.index ##返回value再元组中的索引值