Skip to content

Add files via upload - 已批改2019.4.14#12

Open
SunTestYes wants to merge 1 commit intozhangting85:masterfrom
SunTestYes:master
Open

Add files via upload - 已批改2019.4.14#12
SunTestYes wants to merge 1 commit intozhangting85:masterfrom
SunTestYes:master

Conversation

@SunTestYes
Copy link

第13章大作业

Copy link
Owner

@zhangting85 zhangting85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请重新阅读这一章节的需求。
要求是这个程序要支持命令行调用。

以下是测试用例,没有一个通过的。
python currency_convert.py --field 2 --multiplier 0.8 < data.csv > data-fr.csv
python currency_convert.py --field 2 --multiplier 0.8 -i data.csv > data-fr.csv
python currency_convert.py --field 2 --multiplier 0.8 -i data.csv -o data-fr2.csv
python currency_convert.py --field 2 --multiplier 0.8 -i data.csv
python currency_convert.py --help
python currency_convert.py --field 2 --multiplier 0.8 -i "pivotsense,7.99,Pivotal Sense (ltd.),1483820006,/dl area/pivotsense.tgz,/r/ps.tgz"
python currency_convert.py --field 2 --multiplier 0.8 -i data-fr.csv > data3.csv

你这个脚本失败的原因是不支持上面这种直接命令行调用。
也就是说,没有把这个作业当做一个通用的linux命令行程序来写。

当我们使用linux操作系统时,往往会需要使用命令行程序。
这些命令行程序一般都是以 “命令 参数表”的形式来做的。而不是你这样通过循环读取用户输入来做。
(题外话,你这种做法的程序也有,但是多半不是普通linux程序,这种程序一般称为xx cli,然后有自己的另外一套标准做法)
为什么呢?
因为linux程序往往会作为自动化脚本的一部分。因此我们写任何在linux上运行的命令行程序的大前提是要可以放进脚本里自动化,比如这样的脚本:

cd A
python currency_convert.py --field 2 --multiplier 0.8 < data.csv > data-fr.csv
cd B
python currency_convert.py --field 2 --multiplier 0.8 < data.csv > data-fr.csv

这样他打开A目录,把A目录的一个文件做了转化,再打开B目录,把B目录的一个文件做了转化。
这种shell脚本写复杂点,可以实现对一个目录下所有文件批量转化的功能。因此扩展性大大优于你的实现。

回到大作业上,大作业的要求是按需求实现,而不是你自己不按需求随意实现。所以,这个提交是不通过的。如果需要批改,请修改并自己测试过之后重新提交。

@@ -0,0 +1,88 @@
import re
print('欢迎使用我开发的转换器,请将转换器和要被处理的csv文件放在相同路径下,不然我无法为您工作,谢谢您的理解和支持!')

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

完全没有按照需求实现

@zhangting85 zhangting85 changed the title Add files via upload Add files via upload - 已批改 Apr 14, 2019
@zhangting85 zhangting85 changed the title Add files via upload - 已批改 Add files via upload - 已批改2019.4.14 Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants