Python学习笔记 - 1.变量.表达式.语句
2016-02-26 16:04
826 查看
确定类型
type()方法可以确定一串输入的格式:type('Hello,World') type(17)
语义错误
数字如果用逗号隔开,Python中会认为这是三个数字,而分别打印>>print 1,000,000 1 0 0
python的31个保留关键字
python解释器使用保留关键字来识别程序的结构and del from not while
as elif global or with
assert else if pass yield
break except import print
class exec in raise
continue finally is return
def for lambda try
运算符和运算对象
+、 -、 、 /和*五个运算符分别代表加、 减、 乘、 除和次方的运算
Python中3种除法
1.传统除法(整数除法则执行地板除,如果是浮点数除法则执行精确除法)2.精确除法(from future import division)
3.地板除(操作符 //)
4.补充:内建函数divmod()
divmod (a,b),返回(a//b,a%b)
运算顺序
遵照数学运算习惯, “先括号再次方接着乘除后加减”( PEMDAS)输入函数
input = raw_input() name = raw_input('What is your name?\n')
强制类型转换
int()函数,int(speed),float()注意,括号加到后面
python中的注释以#开头
关键字
for word in words: print word
调试
“use before def;”, 这个错误的意思是使用了一个还没有赋值的变量变量名区分大小写
print不换行打印
语句后加个逗号“,”>> print "Hello,world",10 Hello,world 10
相关文章推荐
- python在Windows下运行时编码问题
- python的zip函数
- python matplotlib中文显示乱码解决
- Python文件操作
- python urllib2库
- python读取access文件并入库
- python的list要打印中文字符
- 在python3.5下安装scrapy包
- Python面向对象编程
- Python 3 之 装饰器详解
- python翻译[排序高级]
- python XPath
- win64下安装numpy-scipy-matplotlib-scikit-learn
- python语言特性(四)
- Python的list循环遍历中,删除数据的正确方法
- Python中的*args和**kwargs
- python处理excel
- python 入门
- Python中的两种结构dict和set
- python __call__函数