1
|
open(name[,mode[,buffering]])
|
1
|
>>>x = open(r
'c:\text\a.txt'
)
|
1
2
3
4
|
>>>f = open(
'a.txt'
,
'w'
)
>>>f.write(
'hello,'
)
>>>f.write(
'iplaypython'
)
>>>f.close()
|
1
2
3
|
>>>f = open(
'a.txt'
,
'r'
)
>>>f.read(
5
)
'hello'
|
1
2
|
1
、read( ):表示读取全部内容
2
、readline( ):表示逐行读取
|