信息录入与查找系统有偿,指点。
❷ Python程序设计
import os
f=open("D:\speech.txt")
all = f.readlines() # 读取文本中所有内容,并保存在一个列表中,列表中每一个元素对应一行数据
s=[]
print(all)
for i in all:
k=i.split(' ')
for j in k:
s.append(j)
print(s)
print("文件大小(bite)是:"+str(os.path.getsize("D:\speech.txt")))
print("单词个数是:"+str(len(s)))
显示:
E:\Django_lianxi\venv\Scripts\python.exe D:/Test_work/test.py
['I have an apple,you have a dog,\n', 'your dog eat my apple.\n', "what't a fuck."]
['I', 'have', 'an', 'apple,you', 'have', 'a', 'dog,\n']
['I', 'have', 'an', 'apple,you', 'have', 'a', 'dog,\n', 'your', 'dog', 'eat', 'my', 'apple.\n']
['I', 'have', 'an', 'apple,you', 'have', 'a', 'dog,\n', 'your', 'dog', 'eat', 'my', 'apple.\n', "what't", 'a', 'fuck.']
文件大小(bite)是:71
单词个数是:15