1

Sl No , Task , Date , Hrs

1、代理投标新流程开始接受所有投标作为代理投标,12-11-12,8小时

2,代理投标新流程接受所有投标作为代理投标在本地机器完成,14-Nov-12 4hrs

3,代理投标新流程接受所有投标作为代理投标上传到测试服务器,然后在实时服务器中完成测试,16-11-12,6小时

这就是我的 excel 表的样子,现在我想在 python 中创建一个函数,该函数将采用 Date 的输入参数,或者也可能是 Task 并返回 Hrs。

可能吗?

提前致谢。

4

1 回答 1

0

尝试使用此代码。假设 f1.csv 是文件。

import os

str1 = '"Proxy bid new flow of accepting all the bids as proxy bid started"'

def get_hours(str1):
   cmd1 = 'grep -R '+str1 +' f.csv'
   result = os.popen(cmd1).read()
   hrs = result.split(',')[-1]
   print hrs
   return hrs

get_hours(str1)
于 2015-10-08T10:32:26.347 回答