Print 출력
"sep = " : 여러개 문자들을 구분하여 출력하는 법
# test_1 test_2 test_3 출력
print('test_1 ', 'test_2 ', 'test_3 ')
# test_1;test_2;test_3 출력
print('test_1', 'test_2', 'test_3', sep=';')
"end= " : print 함수의 경우, \n 자동 줄바꿈이 디폴트로 되어있음. end=" " 설정 시, 줄바꿈 없음
# 자동 줄바꿈
print('test_1')
print('test_2')
# 줄바꿈 없이 출력
print('test_1', end="")
print('test_2', end="")
한줄에 여러개의 코드를 작성하고 싶을때, ; (세미콜론을) 붙여서 한줄에 써줌
# 한줄에 한명령어
print('test_1')
print('test_2')
# 한줄에 여러 명령어 사용시,
print('test_1'); print('test_2')
format
# format 사용
name = 'lee'
age = 20
print('my name is {} and age is {}'.format(name, age))
'Python Tutorial' 카테고리의 다른 글
[ Python Tutorial ] 클래스 (0) | 2022.12.26 |
---|---|
[ Python Tutorial ] 딕셔너리 (0) | 2022.12.12 |
[ Python Tutorial ] 튜플 (1) | 2022.12.10 |
[ Python Tutorial ] 리스트 (0) | 2022.12.09 |
[ Python Tutorial ] 문자열 (0) | 2022.12.08 |