2014-01-01から1年間の記事一覧

warnで警告を表示させる

warnings.warn を使うと警告文を表示させることができる。 import warnings warnings.warn('警告です') print('hello world') # プログラムは続行 実行するとstderrに警告文が表示されるものの、プログラムは停止せず、そのまま実行を継続する。 C:\temp\scr…

tkinterでは基本多言語面しか使えない

Python の tkinter.Entry に入力した内容を取り出そうとすると、こういう例外が出る文字がある。 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: invalid continuation byte 何とか迂回できないものかと、対話モードで色々弄って…

time.strftime で UnicodeEncodeError が出るんだが

WindowsのPython3で、time.strftimeに日本語を渡すと例外が出る。 >>> import time >>> time.strftime("%Y年%m月%d日") Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in p</module></stdin>…