IT
[python]float 또는 int로 문자열을 구문 분석합니까?
float 또는 int로 문자열을 구문 분석합니까? 질문 How can I convert a str to float? "545.2222" → 545.2222 How can I convert a str to int? "31" → 31 답변 >>> a = "545.2222" >>> float(a) 545.22220000000004 >>> int(float(a)) 545 답변String이 float인지 확인하는 Python 메서드 :def is_float(value): try: float(value) return True except: return False 이 함수의 더 길고 정확한 이름은 다음과 같을 수 있습니다 : is_convertible_to_float (값)무엇이 뭐야, 파이썬에서 부유물이 아닌 것..
2022. 4. 13. 12:38
최근댓글