gpt4 book ai didi

python - 值错误 : Invalid character found in sheet title

转载 作者:行者123 更新时间:2023-12-04 16:29:08 27 4
gpt4 key购买 nike

此 Python 代码失败:

from openpyxl import Workbook

wb = Workbook()
sheet = wb.create_sheet('*nice*')

异常(exception):

/home/foo/local/bin/python /home/foo/src/invalid.py
Traceback (most recent call last):
File "/home/foo/src/invalid.py", line 5, in <module>
sheet = wb.create_sheet('*nice')
File "/home/foo/local/lib/python2.7/site-packages/openpyxl/workbook/workbook.py", line 158, in create_sheet
new_ws = Worksheet(parent=self, title=title)
File "/home/foo/local/lib/python2.7/site-packages/openpyxl/worksheet/worksheet.py", line 121, in __init__
_WorkbookChild.__init__(self, parent, title)
File "/home/foo/local/lib/python2.7/site-packages/openpyxl/workbook/child.py", line 50, in __init__
self.title = title or self._default_title
File "/home/foo/local/lib/python2.7/site-packages/openpyxl/workbook/child.py", line 93, in title
raise ValueError(msg)
ValueError: Invalid character * found in sheet title

如何创建标题中包含*的工作表?

最佳答案

我们可以使用星号 (*) 符号创建工作表吗?

sheet = wb.create_sheet("&nice")

根据this ,我们不能在工作表名称中使用以下特殊字符

\/*[]:?

关于python - 值错误 : Invalid character found in sheet title,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55397776/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com