赞
踩
- file_name='a.txt'
- line_count=0
- word_count=0
- character_count=0
- with open(file_name,'r',encoding='utf-8') as f:
- for line in f:
- word=line.split()
- line_count+=1
- word_count+=len(word)
- character_count+=len(line)
- print('行数:',line_count)
- print('单词数:',word_count)
- print('字母数:',character_count)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。