Always Show 4 Decimal Places
问题 Is it possible to force a cell to always show 4 decimal places using xlwt? Regardless of the number actually present after the decimal place. I have done some searching and I can find a string to always reduce to 2 decimal places, but I need certain cells on my sheet to show 4. 回答1: Use xlwt styles. Here's a simple example: import xlwt book = xlwt.Workbook() sheet = book.add_sheet("test") decimal_style = xlwt.XFStyle() decimal_style.num_format_str = '0.0000' sheet.write(0, 0, 1.23456789,