본문 바로가기
python

Python 자료형

by 뎅규르르 2020. 5. 27.

1. int형

>>> number = 10
>>> type(number)
<type 'int'>
>>> number = int(10)
>>> type(number)
<type 'int'>

2. float형

>>> number = 10.0
>>> type(number)
<type 'float'>
>>> number = float(10)
>>> type(number)
<type 'float'>

3. bool형 - True, False

>>> result = True
>>> type(result)
<type 'bool'>
>>> result = False
>>> type(result)
<type 'bool'>
>>> result = bool(1)
>>> type(result)
<type 'bool'>
>>> result

True
>>> result = bool(100)
>>> type(result)
<type 'bool'>
>>> result
True

>>> result = bool(0)
>>> type(result)
<type 'bool'>
>>> result
False

4. None형

>>> blank = None
>>> type(blank)
<type 'NoneType'>

 


5. str형

>>> s = "hello world"
>>> s
'hello world'
>>> type(s)
<type 'str'>
반응형

'python' 카테고리의 다른 글

[python] dict 를 list로 변환시키기  (0) 2021.10.08
[python] json 을 dict로 변환시키기  (0) 2021.10.08
[python] enumerate  (1) 2021.04.04
[python] MAC M1 python 설치하기  (5) 2021.01.30
python 문자열 인덱싱  (0) 2020.05.27

댓글