2017-07-28 78 views
0

我的目標是創建一個與PyLatex的浮動表,要做到這一點我想使用類Table。但是,當我初始化Table我得到以下錯誤:PyLatex初始化錯誤表

Traceback (most recent call last): 
    File "table.py", line 18, in <module> 
    table = Table('rc|cl') 
TypeError: __init__() takes exactly 1 argument (2 given) 

這確實是令人困惑,因爲我認爲'rc|cl'爲1的說法。爲了確保我沒有任何錯誤,我執行了Nullege中的一個腳本,導致上述錯誤。

+0

'table = Table()'做什麼? –

+0

然後表被初始化,但是我得到錯誤「Table」對象沒有屬性'add_hline'。我認爲這個例子是錯誤的。 – gillesB

+0

不應該是「表格」而不是「表格」? – Feodoran

回答

1

正如Feodoran在他的評論中提到的,Tabular必須包裹在一張桌子內才能使其浮動。

doc = Document() 

with doc.create(Table()): 
    with doc.create(Tabular("llr")) as tabular: 
     tabular.add_row(("Foo", "Bar", "Foobar")) 
     tabular.add_hline() 
     # etc