个人项目
1、Github项目地址:
2、估计开发时间:
|
PSP2.1 |
Personal Software Process Stages |
预估耗时(分钟) |
实际耗时(分钟) |
|
Planning |
计划 |
|
|
|
· Estimate |
· 估计这个任务需要多少时间 |
|
|
|
Development |
开发 |
|
|
|
· Analysis |
· 需求分析 (包括学习新技术) |
|
|
|
· Design Spec |
· 生成设计文档 |
|
|
|
· Design Review |
· 设计复审 (和同事审核设计文档) |
|
|
|
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
|
|
|
· Design |
· 具体设计 |
|
|
|
· Coding |
· 具体编码 |
|
|
|
· Code Review |
· 代码复审 |
|
|
|
· Test |
· 测试(自我测试,修改代码,提交修改) |
|
|
|
Reporting |
报告 |
|
|
|
· Test Report |
· 测试报告 |
|
|
|
· Size Measurement |
· 计算工作量 |
|
|
|
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
|
|
|
合计 |
|
|
|
3、刚看到题目的时候想起用过python爬虫所以就使用了python,在测试的时候发现python对于解析编码格式有很多问题,所以浪费了很多时间在寻找解决的办法上。
4、对每个功能分函数进行,返回文件字符数,文件单词数,文件行数。
5、(1)用charnum逐个读取字符数实现统计字符数
def charnum(path):
try:
num = 0
with open(path, "r") as f:
while(True):
line = f.read(1)
if not line:
break
num += 1
f.close()
print('文件字符数:',num)
except:
print('读取文件错误')
f.close()
(2)用wordnum对单词进行统计,设置标志域来实现
def wordnum(path):
try:
tag = 1
with open(path, "r") as f:
while(True):
wo = f.read(1)
if not wo:
break
if ord(wo) not in (97,122) and ord(wo) not in (65,90)):
if tag == 1:
num+=1
tag=0
elif:
tag=1
print('文件单词数:' ,num)
except:
print('读取文件错误')
(3)linenum进行行数统计
def linenum(path):
try:
f = open(path, 'r')
num = len(f.readlines())
print('文件行数:',num)
f.close()
except:
print('读取文件错误')
f.close()
(4)主程序
while(True):
print('-------------------')
print('欢迎使用文件处理系统')
print('请选择你要实现的功能')
print('c:统计文件字符数\nw:统计文件单词数\nl:统计文件行数\na:统计文件空行、代码行与注释行\no:退出\n')
choice = input()
if choice == 'o':
break
print('请输入文件名')
path= input()
switch(choice)
6、运行测试
测试样本

(1)统计字符

(2)统计文件行数

7、通过这个题目发现自己技术太差,以后需要多练习编程技术。

浙公网安备 33010602011771号