标签:
ID, name, score1302303069, qxj511, 98.801302303070, zhy, 99.90
fd = open("qxj511.txt","r")st = fd.readlines()print st // 一次性打印列表的所有的成员for s in st:s = s.rstrip("\n")print s // 逐一打印fd.close()
fd = open("qxj511.txt","w")li = [1302303069,"qxj511",88.88]lj = [1302303070,"zhy",99.99]for s2 in li: // 列表依次取出fd.write(str(s2)) // 依次写入,这里使用 str 将列表的内容转为字符串写入fd.write(" ")fd.write("\n")i = 0while i<=len(lj)-1 : // 使用 while的方式写入,fd.write(str(lj[i]) + " ")i = i + 1fd.close()
标签:
原文地址:http://www.cnblogs.com/qxj511/p/4918827.html