不学无术
发布时间:2015-03-16 16:26:42
>>> li = ['a', 'b', 'c'] >>> li.extend(['d', 'e', 'f']) >>> li ['a', 'b', 'c', 'd', 'e', 'f'] >>> len(li) &nb.........【阅读全文】
发布时间:2015-03-10 15:21:56
替换oldtxt,newtxtfor line in fileinput.input("filepath",inplace=1): line=line.replace("oldtxt",“newtxt”) print line例子2(f1 = file("hello.txt", "r")f2 = file("myhello.txt", "w")for s in f1.readlines(): f2.writes(s.replace("h.........【阅读全文】