728x90
자료 유형 |
자료형 | 형 변환 함수 |
정수(integer) | int | int() |
실수(floating-pointer) | float | float() |
문자열(string) | str | str() |
>>> x = '3.14'
>>> x1 = float(x)
>>> x1
실행결과 : 3.14
>>> x2 = int(x1)
>>> x2
실행결과 : 3
>>> x3 = str(x2)
>>> x3
실행결과 : '3'
>>> print(type(x1),type(x2),type(x3)) # 변수의 자료형을 확인
실행결과 : <class 'float'> <class 'int'> <class 'str'>
728x90
'Programming > Python' 카테고리의 다른 글
Python 반복문 사용하기(for, while) (0) | 2020.01.08 |
---|---|
Python 조건문 사용하기(if, if-else, if-elif-else..) (0) | 2020.01.07 |
Python 값 입력 및 다중 대입하기 (0) | 2020.01.07 |
Python 자료형(튜플, 딕셔너리, 집합) (0) | 2020.01.06 |
Python 자료형(숫자형, 문자형, 리스트) (0) | 2020.01.06 |