Python基础3.X

从实例学习Python

1、运行python文件时传递参数。

在控制台运行命令:python test.py 2003 2001 2000

这里传递了四个参数,通过sys.argv可以获得所有参数,

2、将字符串转换为整数

Python3.x:locale.atoi(str)

Python3.x:string.atoi(str);

3、获取最大整数

Python3.xsys.maxsize

Python2.xmaxint

4、Python3.x取消了Long数据类型,全部使用int类型

Python2.x int类型转换为long数据类型:long(int)

5、Python3.xprint输出方式:

如果不需要换行:则加入end参数,并设置end参数为空

如:print(“”,end=””)

6、python3.x,print函数应为print(),不存在dict.iteritems()这个函数。

7、在python中写中文注释会报错,这时只要在头部加上# coding=gbk即可

参考书籍:Python程序员指南

posted @ 2013-09-09 17:57  Blue Blue  阅读(255)  评论(0)    收藏  举报