通过 python 中的 xlwings 在 Excel 中进行数字格式化(int 到逗号分隔)
我对编程有点陌生。 我的代码运行完美。但是,我想将 excel 的输出数字分隔为“XXX,XXX”而不是“XXXXXX”。你能建议一下吗?
这是我的功能代码:
def main():
wb = xw.Book.caller()
wrd_input = input("Enter your word file name:")
sht_input = input("Enter Panel sheet name:")
oput_name = input("Enter output name for your document:")
sht_panel = wb.sheets[sht_input]
doc = DocxTemplate(wrd_input +'.docx')
context = sht_panel.range("A2").options(dict, expand="table", numbers=int).value
output_name = oput_name + '.docx'
doc.render(context)
doc.save(output_name)
I'm kind of new to programming.
My code runs perfectly. However, I would like to separate the output numbers from excel to "XXX,XXX" instead of "XXXXXX". Can you please advise?
Here is my function code:
def main():
wb = xw.Book.caller()
wrd_input = input("Enter your word file name:")
sht_input = input("Enter Panel sheet name:")
oput_name = input("Enter output name for your document:")
sht_panel = wb.sheets[sht_input]
doc = DocxTemplate(wrd_input +'.docx')
context = sht_panel.range("A2").options(dict, expand="table", numbers=int).value
output_name = oput_name + '.docx'
doc.render(context)
doc.save(output_name)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论