배우고 느낀 것들
인프런 파이썬 입문 초반 3강 본문
sep='A' 프린트 안에 , 로 구분 된 요소들 사이에 A 넣어줌
EX) Print("010", "1234" , "5678", sep="-")
-> 010-1234-5678
end= "A"
Print 쓰면 줄바꿈 자동으로너무 많이 되는 걸 방지해줌. "" 으로 놔두면 한 줄로 쭉 이어줌
Print 쓰면 줄바꿈 자동으로너무 많이 되는 걸 방지해줌. "" 으로 놔두면 한 줄로 쭉 이어줌
format 사용 : d정수 ,s문자열 ,f숫자
print( '%s %s' & ( 'one' , 'two')
나
print('{} {}' , format('one','two'))
결과는 동일 , 1번이 더 정석적
{} 안에 0,,1,2 ... 넣어서 순서 설정 간가능
%만 되는건가? 다른 기호로 하니까 안됨....
one two
print('@s %s' @('one') %('two'))
Traceback (most recent call last):
File "", line 1, in
print('@s %s' @('one') %('two'))
TypeError: unsupported operand type(s) for @: 'str' and 'str'
print('@s %s' @('one') %('two'))
Traceback (most recent call last):
File "", line 1, in
print('@s %s' @('one') %('two'))
TypeError: unsupported operand type(s) for @: 'str' and 'str'
안 되는 거 맞는 거 같은데 다른 기호 되는거면 가능?
s + print
: s에 해당하는 숫자만큼 칸을 확보. s는 d,f와 달리 생략 가능. (기본값이 s?)
. 붙이면 그보다 긴 건 절삭
print ('%10s' % ('nice'))
nice
print('{:>10}' ,format('nice'))
{:>10} nice
print('{:>10)')
{:>10)
KeyboardInterrupt
print('{:>10}' ,format('nice'))
{:>10} nice
print('{:>10}'.format('nice'))
nice
print('{:<10}'.format('nice'))
nice
d: 정수
f : 정수부와 소수부 구분
: s에 해당하는 숫자만큼 칸을 확보. s는 d,f와 달리 생략 가능. (기본값이 s?)
. 붙이면 그보다 긴 건 절삭
print ('%10s' % ('nice'))
nice
print('{:>10}' ,format('nice'))
{:>10} nice
print('{:>10)')
{:>10)
KeyboardInterrupt
print('{:>10}' ,format('nice'))
{:>10} nice
print('{:>10}'.format('nice'))
nice
print('{:<10}'.format('nice'))
nice
쉼표, 마침표 구분. 괄호 순서 틀리면 안댐!!!
print('{:$>10}'.format('nice'))
$$$$$$nice
print('{:^>10}'.format('nice'))
^^^^^^nice
print('{:^10}'.format('nice'))
nice
$$$$$$nice
print('{:^>10}'.format('nice'))
^^^^^^nice
print('{:^10}'.format('nice'))
nice
d: 정수
f : 정수부와 소수부 구분
여행 와서 괜히 노트북 들고왔나 싶었는데, 게시글 하나라도 남기니까 좀 뿌듯하닿
따라는 하는데, 이게 왜 중요한지 모르겠음
'파이썬 > 강의' 카테고리의 다른 글
인프런 파이썬 강의 섹션6 (0) | 2022.08.24 |
---|---|
인프런 챕터5 , 함수 (0) | 2022.08.19 |
인프런 , 파이썬 흐름 제어 (0) | 2022.08.17 |
인프런 파이썬 입문 강의 섹션3 - 자료형 (0) | 2022.08.14 |
파이썬 1일차 - 생활코딩 파이썬 입문 강의 (0) | 2022.07.17 |
Comments