내장함수 - class float([x])

2015. 7. 20. 11:09IT관련

반응형

https://docs.python.org/2/library/functions.html#float


class float([x])

문자열 x를 실수인 float class로 변환하여 리턴한다.



>>> float(0)

0.0

>>> float(1)

1.0

>>> float(-1)

-1.0

>>> float(-1.1)

-1.1

>>> float(1.1)

1.1

>>> float('z')

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

ValueError: could not convert string to float: z



반응형