Python 我为2或3个输入编写了代码,但对于许多输入,我应该怎么做
如果你说不要写太多代码,我认为你应该使用循环,对于循环,如下所示:Python 我为2或3个输入编写了代码,但对于许多输入,我应该怎么做,python,python-3.x,numpy,Python,Python 3.x,Numpy,如果你说不要写太多代码,我认为你应该使用循环,对于循环,如下所示: print("Store Room Stock Category") print("") print("") Stockmachinary1 = input("Enter the stock material name:") Stockmachinary1price=int(input("Enter the stock material price:")) Stockmachinary2=input("Ente
print("Store Room Stock Category")
print("")
print("")
Stockmachinary1 = input("Enter the stock material name:")
Stockmachinary1price=int(input("Enter the stock material price:"))
Stockmachinary2=input("Enter the stock material name:")
Stockmachinary2price=int(input("Enter the stock material price:"))
Stockmachinary3=input("Enter the stock material name:")
Stockmachinary3price=int(input("Enter the stock material price:"))
Totalstockprice=Stockmachinary1price+Stockmachinary1price+Stockmachinary3price
import pandas as pd
stock = pd.DataFrame({"stock":[Stockmachinary1,Stockmachinary2,Stockmachinary3,"totalcoststock"],\
"price":[Stockmachinary1price,Stockmachinary2price,Stockmachinary1price,Totalstockprice]})
stock=stock[["stock","price"]]
stock
Totalstockprice
但如果你谈论巴赫的数据输入,我认为你可能需要csv或其他文件格式的输入。熊猫和它配合得很好。这是帮助页面:
这里没有问题,只要代码。欢迎来到StackOverflow!请阅读有关和的信息。这将使其他人更容易帮助你。这不是一件容易的事,兄弟
print("Store Room Stock Category")
print("")
print("")
StockmachinaryNames = []
StockmachinaryPrice = []
counts = int(input("Enter the stock material you want input:"))
for i in range(counts):
Name = input("Enter the stock material name:")
Price=int(input("Enter the stock material price:"))
StockmachinaryNames.append(Name)
StockmachinaryPrice.append(Price)
TotalstockPrice = sum(StockmachinaryPrice)
StockmachinaryNames.append("totalcoststock")
StockmachinaryPrice.append(TotalstockPrice)
import pandas as pd
stock = pd.DataFrame({"stock":StockmachinaryNames,\
"price":StockmachinaryPrice})
stock=stock[["stock","price"]]
print(stock)
print(TotalstockPrice)