Print

gyomni·2021년 12월 16일
0

Python

목록 보기
4/12
post-thumbnail

# 기본 출력

print('hello')
print("HEllo")
print("""Hi""") # Hi
print('''Bye''') # Bye	

# seperator 옵션 사용

print('T','E','S','T')
print('T','E','S','T',sep='')
print('2021','12','16',sep='-') # 2021-12-16
print('gyomni','gmail.com',sep='@') # gyomni@gmail.com

# end옵션

print('welcome to ', end='')
print('the black parade', end=' ')
print('piano')
# welcome to the black parade piano

# format 사용 [], {}, ()

print('{} and {}'.format('you', 'me')) # you and me
print("{0} and {1} and {0}".format('you','me')) # you and me and you
print("{a} = {b}".format(a='you', b='me')) # you = me

# %

print("%s's favorit number is %d" %('gyomni',3)) # %s:문자, %d:정수, %f:실수 
						 # gyomni's favorit number is 3

print("Test1 : %5d, price: %4.2f" %(77683889, 6543.888)) # 5d% : 5자리 정수, %4.2f: 4자리 정수 & 2 소수점아래2자리 // Test1 : 77683889, price: 6543.89
print("Test1 : {0:5d}, price : {1:4.2f}".format(6 , 6543.6543)) # Test1 :     6, price : 6543.65
print("Test1: {a: 5d}, Price: {b:4.2f}".format(a=776, b= 43.56)) # Test1:   776, Price: 43.56

# '' , " ", \, \n, \t,

print("'you'") # 'you'

print('\'you\'') # 'you'
print('"you"') # "you"
print("""'you'""") # 'you'
print('\\you\\\n') # \you\ (한줄 띄움)

print('test') # test
print('\t\ttest') #                 test (tab 두번)
profile
Front-end developer 👩‍💻✍

0개의 댓글