"TypeError"의 두 판 사이의 차이

20번째 줄: 20번째 줄:
# 2.0
# 2.0
# False
# False
</source>
<source lang='Python'>
iter(1)
# TypeError: 'int' object is not iterable
</source>
</source>


==같이 보기==
==같이 보기==
*[[ZeroDivisionError]]
*[[ZeroDivisionError]]

2014년 8월 22일 (금) 09:08 판

TypeError

1 Python

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

print( divide( 4, 2 ) )
print( divide( 4, '2' ) )
# 2.0
# False
iter(1)
# TypeError: 'int' object is not iterable

2 같이 보기

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