[英]I want to to be able to print the name of the keys in the dictionary then the description, value and quantity
[英]I want to be able to locate a value in excel from python and print the value in the next column
我试图让用户在python中给我一个值,然后代码在excel文档中找到该值并从下一列中打印该值。
我似乎找不到任何代码,而我正在努力自己编写它,到目前为止,这是我的代码:
dotill = input("would you like to enter till mode?")
if dotill == "yes":
barcode = input("please start scanning")
find (bardcode) in:
excel_document = openpyxl.load_workbook('scanza.xlsx',data_only=True)
heet = excel_document['completetransaction']
有人可以帮忙吗?
您可能想看看pandas包。 它提供了与excel的接口。
然后,可以使用来自excel文件的pandas DataFrame来解决您的问题的一部分,该文件的路径为PATH / TO / WORKSHEET beeing,搜索值TESTVALUE,该值将在以下示例中替换:
import pandas as pd
df = pd.read_excel(PATH/TO/WORKSHEET)
if TESTVALUE in df.values:
print('Value in sheet!')
else:
print('Value not in sheet!')
pd.read_excel(path)从excel文件生成一个DataFrame。 df.values可为您提供一个值数组。 if语句检查数组中的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.