首页 > 解决方案 > 处理数据后如何从 CSV 文件打印到控制台?

问题描述

我有一个学校项目,我被困在其中,无法弄清楚如何操作 csv 文件中的数据,然后用 Python 将其打印到控制台。任何帮助或指向正确方向都会非常有帮助。

在本作业中,您将阅读一个 csv 数据文件employees.csv。程序应读取文件中的记录并生成工资报告(在屏幕上)。

Python 控制台中的输出应该是什么样子的示例图片

工资单报告基于以前程序中的此信息。您应该使用(或重用)函数来执行以下操作:

Compute the regular hours worked (40 hours and below)
Compute the overtime hours worked (those above 40 hours)
Compute the regular pay (regular hours times regular pay)
Compute the overtime pay (overtime hours times regular pay times 1.5)
Compute the gross pay
Compute the amount of federal tax withheld (12.4% of gross pay)
Compute the amount of state tax withheld (4.9% of gross pay)
Compute the amount of medicare withheld (1.4% of gross pay)
Compute the amount of social security withheld (6.2% of gross pay)
Compute the total deductions (federal tax + state tax + medicare + social security)
Compute the net pay (gross pay - deductions)
Print (to the screen) a clean summary report (see the output above)

将上述所有单独的函数按顺序拉到一起,def main()在函数调用的下方和上方,main()形成一个干净、有据可查的程序。该程序应该有一个main()调用所有其他函数的函数。

非常感谢!

标签: pythoncsvconsoleexport

解决方案


推荐阅读