发布时间:2019-07-17 10:08:44编辑:auto阅读(1781)
#Read and Write from Files#
#coding=utf-8
import codecs
f = open("AccountList.txt","w")
L = u"张三\n李四\n王五\n赵六"
f.write(L)
f.close()
f = open("AccountList.txt","r")
print (f.readline()) #read lines one by one
print (f.readline())
print (f.readline())
print (f.readline())
f.seek(0)
print (f.readlines()) #Output lines as a list
import linecache
m = open("AccountList01.txt","w")
n = u"America\nChina\nJapan\nEngland\nCanda\nGermany"
m.write(n)
m.close()
#m = open("AccountList01.txt","r")
#f.seek(0)
print(linecache.getline("AccountList01.txt",1));
print(linecache.getline("AccountList01.txt",2));
print(linecache.getline("AccountList01.txt",3));
print(linecache.getline("AccountList01.txt",1));
print(linecache.getline("AccountList01.txt",4));
print(linecache.getline("AccountList01.txt",5));
print(linecache.getline("AccountList01.txt",6));
上一篇: python实现单链表
下一篇: python学习总结-----pytho
47484
45786
36784
34317
28955
25589
24436
19606
19102
17627
5458°
6041°
5563°
5632°
6566°
5370°
5370°
5878°
5851°
7163°