E
E
Ernest Vardanyan2020-05-08 00:07:25
Python
Ernest Vardanyan, 2020-05-08 00:07:25

How to use variables instead of numbers in txt='0,1,2,3,4'?

Hello everyone, after parsing, I need to get a beautiful table view in Excel after parsing, I found this code on some forum, it helps to create a table view, but the numbers are indicated there, and I need what I have to parse, that is, use my variables instead of numbers 0,1,2,3,4, how to do it? What happens as a result of this, I will show the screen below.5eb478775cbb4065999809.png

import xlwt

book = xlwt.Workbook()

sheet1 = book.add_sheet("Sheet1")

cols = ["A", "B", "C", "D", "E"]
txt = [0,1,2,3,4]

for num in range(5):
      row = sheet1.row(num)
      for index, col in enumerate(cols):
          value = txt[index] + num
          row.write(index, value)

book.save("test.xls")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question