一、Python的介绍
1、各种编程语言介绍
2、python的介绍
3、python的安装
二、python的基础语法
1、变量
变量定义的规则
>>变量名只能是 字母、数字或下划线的任意组合
>>变量名的第一个字符不能是数字
>>以下关键字不能声明为变量名
['and', 'as', 'assert', 'break', 'class', 'continue','def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from','global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print','raise', 'return', 'try', 'while', 'with', 'yield']
2、注释
单行注释:#print(‘helloworld’)
多行注释:'''hello
world'''
或者"""helo
world"""
3、操作符
>>算术操作符:+ - * / //(地板除) % **
>>比较操作符:> >= < <= == != <>
>>逻辑运算符:or and not
>>赋值操作符:+= -= *= ……
>>优先级
4、基本类型
类型转换:int() float() str()
注意:
>>如果float转int会丢失精度
>>在Python 3里,只有一种整数类型 int,表示为长整型,没有 python2 中的 Long
>>字符串相乘就是重复,不同类型不能相加 ’hello’*2=’hellohello’
5、分支和循环
条件:if else elif
条件表达式(三元操作符)max= x if x > y else y
断言:assert,类似if的近亲,如果条件为假,程序自动崩溃,兵抛出AssertionError异常。如:assert 3 > 4
while循环 while...else...
for循环 for each in range(10)
break、continue关键字