Bläddra i källkod

fix #453: put_table() error when table data is empty with rich header

wangweimin 2 år sedan
förälder
incheckning
8b6298566a
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      pywebio/output.py

+ 4 - 0
pywebio/output.py

@@ -657,6 +657,10 @@ def put_table(tdata, header=None, scope=None, position=OutputPosition.BOTTOM) ->
         tdata = [list(i) for i in tdata]  # copy data
 
     if header:
+        # when tdata is empty, header will not be process
+        # see https://github.com/pywebio/PyWebIO/issues/453
+        if isinstance(header[0], (list, tuple)):
+            header = [h[0] for h in header]
         tdata = [header, *tdata]
 
     span = {}