我试图制作一个管理库存水平的小程序,并想知道如何在python中启动它[关闭](I am trying to make a small program that manages stock level

编程入门 行业动态 更新时间:2024-10-25 20:25:14
我试图制作一个管理库存水平的小程序,并想知道如何在python中启动它[关闭](I am trying to make a small program that manages stock levels and would like to know how to start it in python [closed])

我想开发该程序以便能够从文本文件中检索和显示信息,所以我想知道如何指出它。

我想通过用户输入某个产品代码和通过文本文件搜索它的程序来检索信息。 另外,我希望用户能够输入一定数量的产品,并且程序能够使用文本文件中的单个价格计算总成本。 我需要它来显示相关信息,如项目名称和价格。 我也想要它识别任何未找到的产品。 输出应该几乎就像一张收据。

我还没有任何代码,因为我不知道从哪里开始,但是iIhave已经创建了包含所有数据的文本文件。

这是我的文本文件:

GTIN: 34512340 plain brackets Quantity: 4 Individual Price: 0.50 GTIN: 98981236 product not found GTIN: 56756777 100 mm bolts Quantity: 32 Individual Price: 0.20 GTIN: 90673412 L-shaped brackets Quantity: 6 Individual Price: 1.20 GTIN: 13245627 100 mm nuts Quantity: 32 Individual Peice: 0.20

I would like to develop the program to be able to retrieve and display information from a text file so I would like to know how to point it.

I would like to retrieve the information by the user inputting a certain product code and the program searching through the text file for it. In addition, I would like the user to be able to input a certain quantity of a product and the program be able to calculate the total cost using the individual price from the text file. I need it to display the related information such as an item name and price. I would also like it to identify any products not found. The output should be almost like a receipt.

I do not have any code as of yet as I do not know where to start but iIhave made the text file including all of its data.

This is my text file:

GTIN: 34512340 plain brackets Quantity: 4 Individual Price: 0.50 GTIN: 98981236 product not found GTIN: 56756777 100 mm bolts Quantity: 32 Individual Price: 0.20 GTIN: 90673412 L-shaped brackets Quantity: 6 Individual Price: 1.20 GTIN: 13245627 100 mm nuts Quantity: 32 Individual Peice: 0.20

最满意答案

你可以使用csv模块,你的文本文件必须提供一些规则, (但是你不必使用它可以是空格,冒号(:)等)字符beetwen列:

import csv with open('c.txt', 'r') as cfile: content = csv.reader(cfile, delimiter=',') for row in content: print(row)
# c.txt GTIN, Quantity, Individual Price 34512340 plain brackets, 4, 0.50 34512340 product not found 56756777 100 mm bolts, 32, 0.20 # output ['GTIN', ' Quantity', ' Individual Price'] ['34512340 plain brackets', ' 4', ' 0.50'] ['34512340 product not found'] ['56756777 100 mm bolts', ' 32', ' 0.20']

python csv

You can use csv module, there are some rules your text file must provide like ,(but ofcourse you dont have to use this it can be a space, colon(:) etc.) character beetwen columns :

import csv with open('c.txt', 'r') as cfile: content = csv.reader(cfile, delimiter=',') for row in content: print(row)
# c.txt GTIN, Quantity, Individual Price 34512340 plain brackets, 4, 0.50 34512340 product not found 56756777 100 mm bolts, 32, 0.20 # output ['GTIN', ' Quantity', ' Individual Price'] ['34512340 plain brackets', ' 4', ' 0.50'] ['34512340 product not found'] ['56756777 100 mm bolts', ' 32', ' 0.20']

python csv

更多推荐

本文发布于:2023-07-16 07:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125430.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:想知道   库存   水平   程序   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!