William126

Python实战之文件操作的详细简单练习

['_CHUNK_SIZE', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__lt__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_checkClosed', '_checkReadable', '_checkSeekable', '_checkWritable', '_finalizing', 'buffer', 'close', 'closed', 'detach', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'line_buffering', 'mode', 'name', 'newlines', 'read', 'readable', 'readline', 'readlines', 'seek', 'seekable', 'tell', 'truncate', 'writable', 'write', 'writelines']

fp = open('test.py','r+',encoding='utf-8')
data = fp.read()
print(data)
print("*"*60)
# print(fp.buffer)
# <_io.BufferedReader name='test.py'>

print(fp.fileno())
# 3
# 文件描述符

print(fp.isatty())
# False

print(fp.tell())
# 216

print(fp.flush())
# None
print(fp.seek(26))
# 26
print(fp.truncate())
print(fp.tell())
# 26
print(data)

fp.close()

 

posted on 2017-07-03 11:01  William126  阅读(182)  评论(0编辑  收藏  举报

导航