drag n drop

調べたことを書きます

python

floatをバイト列で表示する

import struct print '%08x' % struct.unpack('<L', struct.pack('>f', <数値>))[0] 例: >>> print '%08x' % struct.unpack('<L',struct.pack('>f',1.0))[0]0000803f おまけ: 逆に、floatのバイト列の文字列から、10進数のfloatに戻す場合 print '%f' % struct.unpack('>f',struct.pack('<L',int(<文字列>,16)))[</l',int(<文字列></l',struct.pack('></l',>…

数値をカンマ区切りの文字列に変換する

'{0:,d}'.format(<数値>) 例: >> '{0:,d}'.format(1234567) '1,234,567' 注意: Python2.7以降 参考: format関数による文字列フォーマット(新しい形式) » Python Snippets

Pythonでウィンドウを作成

目標:WindowsにPythonとPySideをインストールして、ウィンドウを作成