TypeError

Jmnote (토론 | 기여)님의 2014년 8월 21일 (목) 16:39 판 (새 문서: category: Error ;TypeError ==Python== category: Python <source lang='Python'> a = 5 / '2' # TypeError: unsupported operand type(s) for /: 'int' and 'str' </source> <source la...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
TypeError

1 Python

a = 5 / '2'
# TypeError: unsupported operand type(s) for /: 'int' and 'str'
def divide(a, b):
    try:
        c = a / b
    except TypeError:
        return False
    return c

print( divide( 4, 2 ) )
print( divide( 4, '2' ) )
# 2.0
# False

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}