读取库存文件(txt)并写入收据文件(txt)

时间:2016-04-12 13:55:06

标签: csv python-3.x

我正在尝试创建一个读取股票文件并写入发票文件的程序,但经过几周的尝试和搜索答案后,我遇到了问题。有人可以帮忙吗?代码需要能够使用gtin代码读取stock文件并以收据格式写入文件。它还需要计算总订单成本并将其写入收据以及在python shell中显示它。

import csv  
import os   
import math 

gtin = []
stock_list = []
order_total = 0

with open("Stock.txt","r+") as stock:
stock_1 = csv.reader(stock, delimiter=',') #added {, delimiter=','} after stock
for row in stock_1:
    gtin.append(row[0])
    stock_list.append(row)
    print(stock.read())

    choice = False

order = input("What would you like order?")

if order in gtin:
    pass
else:
    print("This is not a valid product")

order_row = gtin.index(order)

item_price = int(stock_list[order_row][2]) / 100
order_total = item_price * order_quantity

print("Your current order total is equal to..." +order_total)

我希望输出为,

What would you like to order? (gtin)
How much would you like to order? (Order_quantity)
This is your order total (Order_Total)

收据外部文本文件将显示订购的商品,订购的数量和总费用。

0 个答案:

没有答案
相关问题