티스토리 뷰

Python

Python, 자료형

hwangyoungjae 2016. 4. 19. 10:59
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

>>> type(1)
<class 'int'> #정수

 

>>> type(3.14)
<class 'float'> #실수

 

>>> type(3-4j)
<class 'complex'> #복소수

 

>>> type('Hello')
<class 'str'> #문자

 

>>> a = ['red','green','gold']
>>> type(a)
<class 'list'> #리스트

 

>>> a = {1,2,3}
>>> type(a)
<class 'set'> #세트

 

>>> a = (1,2,3)
>>> type(a)
<class 'tuple'> #튜플

 

>>> a = dict(a=1,b=2)
>>> b = {'a':1,'b':2}
>>> a
{'a': 1, 'b': 2}
>>> b
{'a': 1, 'b': 2}
>>> type(a)
<class 'dict'> #사전
>>> type(b)
<class 'dict'>

>>> a = True
>>> b = False
>>> type(a)
<class 'bool'> #부울(논리값)
>>> type(b)
<class 'bool'>

'Python' 카테고리의 다른 글

Python, 튜플  (0) 2016.04.19
Python, 세트  (0) 2016.04.19
Python, 리스트  (0) 2016.04.19
Python, Indexing  (0) 2016.04.19
Python, 특수문자  (1) 2016.04.19
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함