편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.
최신판 | 당신의 편집 | ||
8번째 줄: | 8번째 줄: | ||
* 결과가 다르므로 특히 유의해야 함 | * 결과가 다르므로 특히 유의해야 함 | ||
{{소스헤더|Python 2}} | {{소스헤더|Python 2}} | ||
< | <source lang='python'> | ||
print( 1/2 ) | print( 1/2 ) | ||
print( type(1/2) ) | print( type(1/2) ) | ||
# 0 | # 0 | ||
# <type 'int'> | # <type 'int'> | ||
</ | </source> | ||
{{소스헤더|Python 3}} | {{소스헤더|Python 3}} | ||
< | <source lang='python'> | ||
print( 1/2 ) | print( 1/2 ) | ||
print( type(1/2) ) | print( type(1/2) ) | ||
# 0.5 | # 0.5 | ||
# <class 'float'> | # <class 'float'> | ||
</ | </source> | ||
==print문 괄호 필수 ★★== | ==print문 괄호 필수 ★★== | ||
{{소스헤더|Python 2}} | {{소스헤더|Python 2}} | ||
< | <source lang='python'> | ||
print( 'hello' ) | print( 'hello' ) | ||
# hello | # hello | ||
print 'hello' | print 'hello' | ||
# hello | # hello | ||
</ | </source> | ||
{{소스헤더|Python 3}} | {{소스헤더|Python 3}} | ||
< | <source lang='python'> | ||
print( 'hello' ) | print( 'hello' ) | ||
# hello | # hello | ||
print 'hello' | print 'hello' | ||
# Error! invalid syntax | # Error! invalid syntax | ||
</ | </source> | ||
==str과 unicode 통일 ★== | ==str과 unicode 통일 ★== | ||
{{소스헤더|Python 2}} | {{소스헤더|Python 2}} | ||
< | <source lang='python'> | ||
print( type('hello') ) | print( type('hello') ) | ||
print( type(u'hello') ) | print( type(u'hello') ) | ||
# <type 'str'> | # <type 'str'> | ||
# <type 'unicode'> | # <type 'unicode'> | ||
</ | </source> | ||
{{소스헤더|Python 3}} | {{소스헤더|Python 3}} | ||
< | <source lang='python'> | ||
print( type('hello') ) | print( type('hello') ) | ||
print( type(u'hello') ) | print( type(u'hello') ) | ||
# <class 'str'> | # <class 'str'> | ||
# <class 'str'> | # <class 'str'> | ||
</ | </source> | ||
:→ 모든 문자열은 유니코드인 str 클래스(의 인스턴스)이다. | :→ 모든 문자열은 유니코드인 str 클래스(의 인스턴스)이다. | ||
==long → int로 통일== | ==long → int로 통일== | ||
{{소스헤더|Python 2}} | {{소스헤더|Python 2}} | ||
< | <source lang='python'> | ||
print( 2**30 ) | print( 2**30 ) | ||
print( type(2**30) ) | print( type(2**30) ) | ||
69번째 줄: | 69번째 줄: | ||
# 1267650600228229401496703205376 | # 1267650600228229401496703205376 | ||
# <type 'long'> | # <type 'long'> | ||
</ | </source> | ||
{{소스헤더|Python 3}} | {{소스헤더|Python 3}} | ||
< | <source lang='python'> | ||
print( 2**30 ) | print( 2**30 ) | ||
print( type(2**30) ) | print( type(2**30) ) | ||
81번째 줄: | 81번째 줄: | ||
# 1267650600228229401496703205376 | # 1267650600228229401496703205376 | ||
# <class 'int'> | # <class 'int'> | ||
</ | </source> | ||
==같이 보기== | ==같이 보기== |