'''
Created on 2011-4-30

@author: xuqiang
'''

# open file 
#
 open(file, mode) 
#
 file : the file to be opened
#
 mode : open file mode, 'r' the file will only be read
#
                        'w'  only writing and existing file with the same name will be erased
#
                         'a' opens the file for appending
#
                         'r+' read & write
#
                         'b' on windows, use this flag to indicate that open file binary, eg 'wb', 'r+b'
= open('./file.txt''r+');
# read the first line
print(f.readline());
# read the left lines
print(f.readlines());
# tell the file pointer position
print("now the file position is ", f.tell());
# set the file pointer to 0L
f.seek(0);
# close the file
f.close();

相关文章:

  • 2021-09-01
  • 2021-11-16
  • 2021-06-14
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-09-21
  • 2022-12-23
  • 2021-07-16
  • 2021-04-13
  • 2021-12-27
  • 2021-09-27
  • 2021-07-14
相关资源
相似解决方案