python
文章平均质量分 70
nuoshueihe
这个作者很懒,什么都没留下…
展开
-
eclipse中python支持中文
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://world77.blog.51cto.com/414605/467466 最近在学习python编程,开发环境设置好了,是用eclipse + pydev 来做开发的环境,配置好了之后,需要解决的一个关键问题就是老问题了:如何解决代码中的中文问题。。。 其原创 2013-01-07 14:28:18 · 835 阅读 · 0 评论 -
python文件及函数初步
#-*- encoding: utf-8 -*-'''Created on 2013-*-*@author: ****'''f=open("b.txt")#去掉换行符data =[line.strip() for line in f]print dataf.close()print f.closed#以下是文件的内部属性#file.closed True 表示文件已经被关原创 2013-04-27 17:46:09 · 790 阅读 · 0 评论 -
python学习一
#-*- encoding: utf-8 -*-'''Created on 2013-*-*@author: ****'''import sysfrom locale import strsys.stdout.writelines("this is test\n")str = "start to learn python"print strstrprint "%s i原创 2013-04-25 15:31:57 · 1326 阅读 · 0 评论 -
python学习标准库
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: '''#标准库学习#os 模块提供了不少与操作系统相关联的函数import osprint os.system('time 0:03')print os.getcwd()#在使用一些像 os 这样的大型模块时内置的 dir() 和 help() 函数非常有用。 p原创 2013-01-10 14:38:08 · 466 阅读 · 0 评论 -
python学习模块和文件
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: wangkjun'''#导入模块import sequence#引用sequence模块中的函数#print sequence.randomlist(4)#内置函数 dir() 用于按模块名搜索模块定义,它返回一个字符串类型的存储列表:print dir(sequen原创 2013-01-10 11:02:13 · 560 阅读 · 0 评论 -
python学习类方法以及重载
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: '''#定义类class Point: pass#实例pt1= Point()#为类添加属性pt1.x=1;pt1.y=2;print pt1,type(pt1),pt1.x # 1def printPoint(pt): print "("原创 2013-01-09 11:18:12 · 6055 阅读 · 0 评论 -
python学习数据结构
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: wangkjun'''a=(2+3j)print a.real #2.0print a.imag #3.0#不能用int,float,long讲复数转化为实话#abs可以取得模print abs(a) # sqrt(a.real**2 + a.imag**2)#原创 2013-01-09 17:17:28 · 660 阅读 · 0 评论 -
python学习exception
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: '''#程序在执行的过程中产生异常,但不希望程序终止执行,这时就需要#用try和except 语句对异常进行处理。filename = ""while 1: filename = raw_input("please input the filename")原创 2013-01-08 15:11:32 · 632 阅读 · 0 评论 -
python学习文件
#-*- encoding: utf-8 -*-'''Created on 2013-1-8@author: '''f=open("test.dat","w")print f #f.write("this")f.write("is")f.write("test\n") #换行\nf.write("I love Python!\nHello, world\nGood Bye!原创 2013-01-08 14:51:23 · 461 阅读 · 0 评论 -
python学习字典
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: '''#列表和序列的访问索引只能是整数,但是字典的访问索引可以是整数,也可以是字符串#字典的元素以逗号为分隔符,每个元素包含键和键值,他俩用冒号分隔diction1 = {1:"tieto",2:"nsn"}print diction1#创建空字典,再添加元素dict原创 2013-01-08 11:24:32 · 615 阅读 · 0 评论 -
python 学习序列
#-*- encoding: utf-8 -*-'''Created on 2013-1-8@author: '''#在Python中还有另一种叫做序列的数据类型。它和列表比较相近,只#是它的元素的值是固定的。序列中的元素以逗号分隔开#序列和列表相似,只是序列的值不可更改#通常情况下,序列用小括号括起来#一个元素的序列,需要在元素后面加上,否则就认为是stringstr1原创 2013-01-08 10:40:30 · 456 阅读 · 0 评论 -
python学习string
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: **'''#操作符“[]”从字符串中取出任意个连续的字符name = "nsntest"print name[0]print name[3]print name[2+3]#函数len返回字符串的长度:print len(name)#用for语句遍历字符串for原创 2013-01-07 16:49:59 · 3570 阅读 · 0 评论 -
python学习内置函数和while
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: ***'''#函数type,它的作用是显示值和变量的类型print type("hello world")#函数id以值或变量为参数,返回值是一整数,它表示值或变量的唯一标示符#每个值或变量都有一个唯一id,id值与变量或值在内存中的位置相关,可以理解为C语言中的内存地原创 2013-01-07 15:44:25 · 723 阅读 · 0 评论 -
python 学习列表
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: '''#列表是一组任意类型的值,按照一定顺序组合而成的。组成列表的值#叫做元素(Elements)。每一个元素被标识一个索引,第一个索引也是0。列#表中的元素可以是任意类型,甚至是列表类型,也就是说列表可以嵌套。a=1b=10arr = [a,b,"nsn","te原创 2013-01-07 18:03:47 · 1437 阅读 · 0 评论 -
python学习变量
#-*- encoding: utf-8 -*-'''Created on 2013-1-7@author: wangkjun'''#变量和表达式print('helloworld')x=10print xtype (x)name = "test"Name = "python"print name,'\t',Nameprint name, "\n", Name#打原创 2013-01-07 14:31:25 · 437 阅读 · 0 评论 -
eclipse集成python
Install the PyDev plug-in for Eclipse Launch EclipseLaunch Eclipse. A screen like this should appear, where you can choose which workspace to open. (If not, go to File → Switch Works原创 2013-01-07 13:49:11 · 2720 阅读 · 0 评论 -
python学习标准库
http://docs.python.org/2/library/原创 2013-04-19 17:53:47 · 600 阅读 · 0 评论