摘要:6-1 1 #6-1 2 3 #help(string) 4 import string 5 6 str = "helloworld" 7 substr = "h1e" 8 9 if string.find(str, substr) != -1:10 print"substr=%s is part of %s" % (substr, str)11 else:12 print"not substring" View Code 6-2 1 #6-2 2 import string 3 import keyword 4
阅读全文
摘要:5-21 #5-22 def mul(x, y):3 return x * y4 5 print mul(4,5) View Code 5-3 1 #5-3 2 def value_score(num): 3 if 90 a[j]:20 a[i], a[j] = a[j], a[i]21 22 print"New arrary:"23 show_all(a) View Code
阅读全文
摘要:3-8 1 #3-8 2 "makeTextFile.py -- create text file" 3 4 import os 5 ls = os.linesep 6 7 #get filename 8 fname = raw_input() 9 while True:10 11 if os.path.exists(fname):12 print "ERROR: '%s' already exists" % fname13 else:14 break15 all = []16 print "\nEnter lines (
阅读全文