If I enter the value of column a in Python Excel, is it possible for column B to come?

Asked 2 years ago, Updated 2 years ago, 121 views

Is it possible to print 10,000 if I get input like the picture and type "Choi" in column A?

I've been looking for this and that, but it doesn't come out that way.

python excel openpyxl

2022-09-21 16:57

1 Answers

See the example below.

from openpyxl import load_workbook

wb = load_workbook('example.xlsx')
sheet = wb.active

# Made of {'Choi': 10000, 'Kim': 20000, 'Lee': 15000}
pair_cell = dict(zip(map(lambda c:c.value, sheet['A']), map(lambda c:c.value, sheet['B'])))

print (pair_cell['Choi'])
10000


2022-09-21 16:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.