티스토리 뷰
# print가 함수 형태로 변경
(python2)>>>print "Hello","World"Hello World(python3)>>>print("Hello","World")Hello World
또한 인자로 구분자, 끝라인, 출력을 지정할 수도 있다
(python3)>>>print("welcome to", "python", sep="~", end="!", file=sys.stderr)welcome to~python!
# long type이 int type으로 통일
(python2)>>>type(2**31)<type 'long'>>>>sys.maxint2147483647>>>type(sys.maxint)<type 'int'>>>>type(sys.maxint + 1)<type 'long'>(python3)>>>type(2**31)<class 'int'>
# int/int 출력 타입 변경
python2에서는 int/int의 결과값이 int로 나와서 난감했지만, python3에서는 float로 처리된다
(python2)>>>1/20(python3)>>>3/21.5>>>type(3/2)<class 'float'>
# String, Unicode 체계 변경
python2에서는 string과 unicode로 구분이 되어 있었으나, python3에서는 string과 bytes로 구분된다
(python2)>>>type('가')<type 'str'>>>>type('가',decode('utf8'))<type 'unicode'>>>>type(u'가')<type 'unicode'>(python3)>type(u'가')<class 'str'>>>>type('가')<class 'str'>>>>type('가'.encode('cp949'))<class 'bytes'>
'Programming > Python' 카테고리의 다른 글
[Python] Dictionary (0) | 2018.08.26 |
---|---|
[Python] List (0) | 2018.08.25 |
[Python] 반복문 for, while (0) | 2018.08.19 |
[Python] 조건문 if (0) | 2018.08.18 |
[Python] 주석처리 (0) | 2018.08.12 |
댓글