pythonで、コンソール上に、表を表示したいのですが、以下のサンプルコードが、NameError: global name 'callable' is not definedで動きません。
環境は、puppy linux tahrpup 6.0.5、pythonのバージョンは、Python 3.1.4、texttableは1.1.1です。
ちなみに、昨日まで、テーブル表示されていたのに、今日になって突然エラーがでるようになりました。どなたか、エラーの内容から、原因の分かる方はいらっしゃらないでしょうか?
エラーの内容
sh-4.3# python texttable_test.py
Traceback (most recent call last):
File "texttable_test.py", line 15, in <module>
["Mr\nBaptiste\nClement", 1, "Baby"] ])
File "/root/python/account_book/texttable.py", line 368, in add_rows
self.add_row(row)
File "/root/python/account_book/texttable.py", line 347, in add_row
cells.append(self._str(i, x))
File "/root/python/account_book/texttable.py", line 473, in _str
if callable(dtype):
NameError: global name 'callable' is not defined
使ったコード
# -*- coding: utf-8 -*- ########################## #texttable_test.py # ########################## import texttable from texttable import Texttable table = Texttable() table.set_cols_align(["l", "r", "c"]) table.set_cols_valign(["t", "m", "b"]) table.add_rows([ ["Name", "Age", "Nickname"], ["Mr\nXavier\nHuon", 32, "Xav'"], ["Mr\nBaptiste\nClement", 1, "Baby"] ]) print (table.draw() + "\n") table = Texttable() table.set_deco(Texttable.HEADER) table.set_cols_dtype(['t', # text 'f', # float (decimal) 'e', # float (exponent) 'i', # integer 'a']) # automatic table.set_cols_align(["l", "r", "r", "r", "l"]) table.add_rows([["text", "float", "exp", "int", "auto"], ["abcd", "67", 654, 89, 128.001], ["efghijk", 67.5434, .654, 89.6, 12800000000000000000000.00023], ["lmn", 5e-78, 5e-78, 89.4, .000000000000128], ["opqrstu", .023, 5e+78, 92., 12800000000000000000000]]) print (table.draw()) コード
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/20 17:44
2017/11/20 23:47