아래 예시에서 기호를 정확히 구분하여야 한다.
- (+)의 기호를 사용할 경우 문자 사이의 공백이 없으며, (,)의 기호를 사용할 경우 문자 사이의 공백이 생겨 출력시 공백이 같이 출력된다.
#print의 출력값은 동일하다.
print('a','b','c', sep='@')
>> a@b@c
print("a","b","c",sep="")
>> abc
print("a"+"b"+"c")
>> abc
print("a"+"b"+"c", sep="@")
>> abc
큰따옴표와 작은 따옴표의 차이가 있을까?
print("a"+"b"+"c",end="")
print('d','e','f',sep="")
>> abcdef
print("a","b","c",end="")
print('d','e','f',sep="")
>> a b cdef
print("a"+"b"+"c",sep="")
print('d','e','f',sep="")
>>
abc
def
print("{0}월 {1}일은 스승의날입니다.".format(5,15))
>>5월 15일은 스승의날입니다.
print("{1}월 {2}일은 스승의날입니다.".format(5,15))
>> 에러 발생 // IndexError:Replacement index 2 out of range for positional args tuple
print("{0}월 {1}일은 스승의날입니다.".format(5,15,13))
>>5월 15일은 스승의날입니다. // 에러발생 안함
print("net \n flix")
print(" \"큰 따옴표 출력\"")
print(" \\ 역슬래쉬 출력")
>>
net
flix
큰 따옴표 출력
\ 역슬래쉬 출력