Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- Numpy
- Selenium
- C#
- nvidia-smi
- C
- paramiko
- error
- Visual Studio
- VS Code
- Python
- SSH
- ubuntu
- Docker
- windows forms
- OpenCV
- mysql
- pip
- 컨테이너
- pandas
- YOLO
- 오류
- pytorch
- 채보
- Linux
- JSON
- label
- 기타 연주
- 핑거스타일
- 프로그래머스
- C++
Archives
- Today
- Total
기계는 거짓말하지 않는다
Python ValueError: invalid literal for int() with base 10 본문
Python 형 변환 시 다음과 같은 오류를 볼 때가 있다.
ValueError: invalid literal for int() with base 10
아래 코드는 오류를 일으킨다.
str = "35.231"
intVal = int(str)
print(intVal)

string을 int로 형 변환 시 소수점 형식일 경우 우선 float 변환 후 진행한다.
str = "35.231"
intVal = int(float(str))
print(intVal)
'Python' 카테고리의 다른 글
| Python Class 정렬, 정렬 기준 (0) | 2021.08.03 |
|---|---|
| Python Index Error (0) | 2021.08.03 |
| Python OpenCV 웹캠 실시간 읽기 (0) | 2021.07.31 |
| Python OpenCV Error Sequence item with index 0 has a wrong type (0) | 2021.07.31 |
| Python glob module (0) | 2021.07.29 |
Comments
