티스토리 뷰

파이썬

print()

김건우_Jonathan 2022. 12. 28. 17:45

print(출력내용, [, sep=구분자] [, end=끝 문자])

  - sep, end는 옵션값으로 필요한 경우에만 설정함

  - sep : 출력내용이 두 값 이상일 경우 구분자를 두 값 사이에 출력함

  - end : 출력내용 마지막에 출력할 문자를 지정함

            (end값 설정하지 않을 경우 기본값으로 개행 문자 적용됨)



print("Python" "is" "powerful")
print("Python", "is", "powerful")
print("Python"+"is"+"powerful")

Pythonispowerful
Python is powerful
Pythonispowerful

 

 

print("Python", "is", "powerful", sep=";")

Python;is;powerful

print("Python", "is", "powerful", end=";")
print("Python", "is", "powerful")

Python is powerful;Python is powerful

 

 

  • 2진수, 8진수, 16진수
구분 접두어 사용 숫자 사용 예 출력함수
16진법 0x 0 ~ 9, a ~ f 0x2f hex(정수)
8진법 0o 0 ~ 7 0o17 oct(정수)
2진법 0b 0, 1 0b1101 bin(정수)
print(0x2f)
print(0o17)
print(0b1101)

47
15
13

print(hex(47))
print(oct(15))
print(bin(13))

0x2f
0o17

0b1101

'파이썬' 카테고리의 다른 글

Jupyter notebook 설치  (0) 2022.12.28
작업 디렉토리 확인 및 설정  (0) 2022.11.14
딕셔너리, 튜플  (0) 2022.02.04
리스트  (2) 2022.02.04
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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 31
글 보관함