啄木鸟,python讲座,源码
这个是根据啄木鸟社区,一个python讲座,整理的python源码.
以备自查.
---------------------------------------
part1
# -*- coding : utf-8 -*-
#-------------------------------------------------------------------------------
# Name: 啄木鸟社区,某宣讲ppt,代码.
# Purpose:
#
# Author: huanghuan
#
# Created: 14-08-2013
# Copyright: (c) huanghuan 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------import os
from os.path import join,getsize
import sysprint sys.argv[1]for root,dirs,files in os.walk(sys.argv[1]):if 'CVS' in dirs:fn = join(root+'\CVS','ROOT')print root + ' :', fnf = open(fn,'r')r = f.read()if r.startswitch('e:\cvsroot'):open(fn,'w').write('g:\cvsroot')f = open(fn,'r')r = f.read()print r#************** test code ********************t = (1,2,3)
print "type(t) = ", type(t)
print "t[1] = ", t[1]#----------
a = "hello"
print "a = ", a
#print a[0]
print "a[-1] = ", a[-1]#----------
b = list(a)
print "b = ", b
print "b[4:] = ", b[4:]
print "b[3:-1] = ", b[3:-1]b[1:2] = ['a','b','c']
print "b = ", b#-----------
d = dict(zip(b,range(len(b))))
print "d = ", d
print "d.keys() = ", d.keys()
print "d.items() = ", d.items()
--------------------------------------
转载于:
啄木鸟,python讲座,源码
这个是根据啄木鸟社区,一个python讲座,整理的python源码.
以备自查.
---------------------------------------
part1
# -*- coding : utf-8 -*-
#-------------------------------------------------------------------------------
# Name: 啄木鸟社区,某宣讲ppt,代码.
# Purpose:
#
# Author: huanghuan
#
# Created: 14-08-2013
# Copyright: (c) huanghuan 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------import os
from os.path import join,getsize
import sysprint sys.argv[1]for root,dirs,files in os.walk(sys.argv[1]):if 'CVS' in dirs:fn = join(root+'\CVS','ROOT')print root + ' :', fnf = open(fn,'r')r = f.read()if r.startswitch('e:\cvsroot'):open(fn,'w').write('g:\cvsroot')f = open(fn,'r')r = f.read()print r#************** test code ********************t = (1,2,3)
print "type(t) = ", type(t)
print "t[1] = ", t[1]#----------
a = "hello"
print "a = ", a
#print a[0]
print "a[-1] = ", a[-1]#----------
b = list(a)
print "b = ", b
print "b[4:] = ", b[4:]
print "b[3:-1] = ", b[3:-1]b[1:2] = ['a','b','c']
print "b = ", b#-----------
d = dict(zip(b,range(len(b))))
print "d = ", d
print "d.keys() = ", d.keys()
print "d.items() = ", d.items()
--------------------------------------
转载于: