Python 文件内容读取

1 # 读取数据的函数
2 def readData(filename):
3     with open(filename, 'r') as f:
4         data = f.read().lower()
5     data = list(data.split())
6     return data
7 words = readData('deng.txt')
8 print (words)
9 print ('File size is {}'.format(len(words)))

 

posted @ 2017-09-12 15:16  今夜无风  阅读(224)  评论(0编辑  收藏  举报