본문 바로가기

파이썬 print 함수 본문

개발/Python

파이썬 print 함수

Louisus 2020. 6. 10. 23:34
728x90

# print 함수

print('''Hello World
Hello World
Hello World
'''
)

print()

# separator 옵션
print('T', 'E', 'S', 'T', sep='')
print('2020','06','10', sep='-')
print('niceman','google.com', sep='@')

print()

# end 옵션
print('Welcome to', end=' ')
print('the black parade', end=' ')
print('piano notes')

print()

# format 사용 [], {}, ()
print('{} and {}'.format('You', 'Me'))
print('{0} and {1} and {0}'.format('You', 'Me'))
print('{a} and {b}'.format(a='You', b='Me'))

print()

# %s : 문자, %d : 정수, %f : 실수
print("%s's favorite number is %d" % ('Dobi', 7))

print('Test1: %5d, Price: %4.2f' % (776, 16534.123))
print('Test2: {0: 5d}, Price: {1: 4.2f}'.format(776, 6534.123))
print('Test3: {a: 5d}, Price: {b: 4.2f}'.format(a=776, b=6534.123))

 

Hello World

Hello World

Hello World

 

 

TEST

2020-06-10

niceman@google.com

 

Welcome to the black parade piano notes

 

You and Me

You and Me and You

You and Me

 

Dobi's favorite number is 7

Test1:   776, Price: 16534.12

Test2:   776, Price:  6534.12

Test3:   776, Price:  6534.12

'개발 > Python' 카테고리의 다른 글

파이썬 DB 연동 (sqlite3)  (0) 2020.06.11
파이썬 자료형  (0) 2020.06.11
파이썬 반복문  (0) 2020.06.10
파이썬 예외 처리  (0) 2020.06.10
파이썬 파일 읽기, 쓰기  (0) 2020.06.10
Comments