본문 바로가기
Edu/01. Language: Python

print()함수

by Lacuna028 2021. 11. 30.

 

 

 

# 기본 출력
print('Hello Python!')  # 문법적 중요
print("Hello Python!")  # 텍스트 의미
print("""Hello Python!""")
print('''Hello Python!''')
 
 
# separator 옵션 사용(구분자 옵션)
print('T', 'E', 'S', 'T', sep='')        # output: TEST
print('2019', '02', '19', sep='-')       # output: 2019-02-19  
print('niceman', 'google.com', sep='@')  # output: niceman@google.com
 
 
# end 옵션 사용(문장 끝 옵션)
print('Welcome To', end=' ')
print('the black parade', end=' ')
print('piano notes')  # output: Welcome To the black parade piano notes
 
 
# format 사용
print('{} and {}'.format('You', 'Me'))
print('{0} and {1} and {0}'.format('You', 'Me'))
print('{var1} are {var2}'.format(var1='You', var2='Niceman'))

 

# %d: 정수, %f: 실수, %s: 문자
print("Test1: %5d, Price: %4.2f" % (776, 6534.123))
print("Test1: {0:5d}, Price:{1:4.2f}".format(776, 6534.123))
print("Test1: {a: 5d}, Price:{b: 4.2f}".format(a=776, b=6534.123))
 
 

 

'Edu > 01. Language: Python' 카테고리의 다른 글

데이터 타입: 문자열  (0) 2021.11.30
데이터 타입: 숫자형  (0) 2021.11.30
[알고리즘] Queue  (0) 2021.11.13
Type Hints  (0) 2021.09.29
조건문  (0) 2021.09.18