
Python
iteye_19576
这个作者很懒,什么都没留下…
展开
-
Python第一篇
下载地址:2.6版本下载:Python 2.6.5 Final for Windows (14.7 MB)下载:Python 2.6.5 Final for Linux (10.6 MB)3.1版本下载:Python 3.1.2 Final for Windows (14.7 MB)下载:Python 3.1.2 Final for Linux (10.6 MB) eclips...2010-03-24 00:13:12 · 104 阅读 · 0 评论 -
Python小例子-在控制台下模拟用户登录
python核心编程的一个例子,主要是字典的应用''' 小e 在控制台下模拟用户登录'''users = {}def register(): while True: user = input("用户名:") if user in users: print('已存在该用户') ...2010-04-21 22:25:57 · 271 阅读 · 0 评论 -
Python变量名检测
Python核心编程的一个作业,将起课本内的一个例子扩展,引入了keyword模块快,调用一个iskeyword函数来先判断一个变量名是否为关键字,接下来判断变量是否符合命名规则。''' 小e 变量名合法性检测'''import stringimport keywordalphas = string.ascii_letters + '_'allCh = alph...2010-04-21 19:50:32 · 181 阅读 · 0 评论 -
Python的字符串模板
Python的字符串模板,可以无需记住类型的细节。subsitute()#严谨模式,在key缺少的情况下会报一个keyError的异常safe_subsitute()#在key缺少的情况下会原封不动的把字符串输出来from string import Templatestr = Template('to:${to}\ntitle:${title}\ncontext:${con...2010-04-20 15:33:53 · 275 阅读 · 0 评论 -
python文件操作(2)
#python文件读写对象x,y,z = 1,2,3name='woxiaoe'd={'a':1,'b':2}l = ['a','b','c']file = open('object','w')file.write(name + '\n')file.write('%s,%s,%s\n' %(x,y,x));file.write(str(d) + '$' + s...2010-04-01 00:59:19 · 116 阅读 · 0 评论 -
python文件操作(1)
# -*- coding:utf-8 -*- ##写文件myfile = open('hello world','w');myfile.write('hello world');myfile.close(); #读文件myfile = open('hello world','r');str = myfile.readline();print("文件内容:\...2010-04-01 00:17:54 · 94 阅读 · 0 评论 -
[转载]Python中文问题研究
关键字: 中文问题 Python中文问题研究 关键字: Python,中文问题 我曾经在深入浅出java中文问题系列中研究过java的中文问题,现在中文问题已经很少羁绊我在java世界中漫游的脚步了。最近,对Python产生了浓厚的兴趣,谁知道跟中文问题这个老朋友又一次不期而遇。看来,在代码世界中,中文问题会在很长一段时间里跟我们形影不离。这也难怪,谁让...2010-03-31 13:03:55 · 102 阅读 · 0 评论 -
python set
x = set('asdfvcxwe');y = set('cswew');print x ,yprint 'x - y:' print (x - y) print 'x | y:'print (x | y) print 'x & y:'print(x & y)output set(['a', 'c', 'e'...2010-03-25 23:57:06 · 126 阅读 · 0 评论 -
python字典
基于键值映射, user1 = {};user1['name'] = 'woxiaoe'user1['city'] = 'cs'user1['age'] = 1print user1 user2 = {};user2['name'] = 'yiba'user2['city'] = 'cs'user2['age'] = 1mail = {'fro...2010-03-25 23:45:45 · 99 阅读 · 0 评论 -
python中的列表
#listm = [[1,2,3],[4,5,6],[7,8,9]]subM = [row[1] for row in m];print subMprint [row[1] + 1 for row in m]print [row[1] + 1 for row in m if row[1]%2==0] print [m[i][i] for i in [0,1,2] ...2010-03-25 23:15:18 · 155 阅读 · 0 评论 -
python字符串
s = "woxiaoe"print len(s)print "s[0] " + s[0] + '\t' + 's[1] ' + s[1];print "s[-1] " + s[-1] + '\t' + 's[-2] ' + s[-2];print s*10 print 'asS'.isalpha();print dir(s);help(s.decode)...2010-03-25 01:42:06 · 75 阅读 · 0 评论 -
Pythone2
F:\study\Python>python hello_world.pyhello world文件名如果有空格会报错F:\study>python f:\study\python\hello_world.py -> test.txt输出到文件中去在程序的末尾加入raw_input(),不会让窗口立即关闭raw_input('press enter...2010-03-24 00:58:12 · 110 阅读 · 0 评论 -
Python核心编程练系题8-12
编写一个程序,用户给出起始和结束数字后,输出一下内容,显示出两个数字之间所有整形的十进制,二进制,八进制和十六进制表示。如果字符时可以打印的ASCII字符,者要打印出来,如果没有一个是可以打印字符,就省略ASCII那一栏 ''' 小e 输出一定范围内字符的不同表示'''import stringfrom string import Templatedef n...2010-04-22 00:11:00 · 233 阅读 · 0 评论