program/python

[python] 형변환

momoa210 2024. 1. 28. 00:12

print(int(3.5)) --> 3 출력

print(float(3)) --> 3.0 출력

print(int("5")) --> 5 출력

 

pring(str(2) + str(5)) --> 25 출력 

 

age = 7

print(age+ "살") --> error 

print(str(age)+"살") --> 7살 출력 

 

 print(int("Hollo")) -->  error

 

'program > python' 카테고리의 다른 글

[python] type 함수  (0) 2024.01.28
[python] fomat 다루기  (0) 2024.01.28
[python] 문자열 포맷팅  (1) 2024.01.28
[python] 문자열  (0) 2024.01.28
[python] 버림나눗셈 // floor division  (0) 2024.01.27