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)))
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)))
转载于:https://www.cnblogs.com/demo-deng/p/7510309.html