Home
Iron Pythonで遊ぶ
Iron Python
Iron Python入門
WPF/XAMLを使おう
Information
私の本棚
Column
コラム
組み込み関数 float
float([x])
float関数は、引数xを実数に変換します。引数は整数や文字列です。複素数は指定できません。また引数を指定しない場合は、"0.0"を返します。
#coding: shift-jis
a = float(1) ←整数を変換
print a
b = float('1.23') ←文字列を変換
print b+1
c = float() ←引数を指定しない場合
print c
raw_input()
出力画面:
1.0
2.23
0.0