【问题标题】:Python Tkinter output the importet data from a text widgetPython Tkinter 从文本小部件输出导入数据
【发布时间】:2021-07-26 12:49:21
【问题描述】:

我尝试将输入的数据从文本条目写入 excel 文件。

如果我这样做:

address = invoice_address_entry.get("1.0",END)
for item in address:
    worksheet.write(row, col, item)
    row +=1

我将数据作为一列获取

【问题讨论】:

标签: python tkinter text


【解决方案1】:

根据症状,

address = invoice_address_entry.get("1.0",END)

返回一个多行字符串。遍历一个字符串会产生其中的单个字符。

如果您希望其中的每一行位于单独的工作表行中,请先使用.splitlines()

address = invoice_address_entry.get("1.0", END)
for item in address.splitlines():
    worksheet.write(row, col, item)
    row += 1

【讨论】:

  • 您的for 循环有问题。您正在重用 row 变量。
  • @TheLizzard 不错,已修复。
猜你喜欢
  • 2020-06-25
  • 2021-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-22
  • 1970-01-01
  • 2020-09-21
相关资源
最近更新 更多