キツツキ、python講座、ソース_Part1

1917 ワード

これはキツツキコミュニティ、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 sys

print sys.argv[1]

for root,dirs,files in os.walk(sys.argv[1]):
    if 'CVS' in dirs:
       fn = join(root+'\CVS','ROOT')
       print root + ' :', fn
       f = 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()



--------------------------------------