Skip to content
Snippets Groups Projects
Commit 64a1bfce authored by Minseong Kwon's avatar Minseong Kwon
Browse files

Update 문자열 메소드.txt

parent 44e4f2df
No related branches found
No related tags found
No related merge requests found
......@@ -125,12 +125,14 @@ ValueError: expected '}' before end of string
>>> a='My name is {0}. I am {1} years old and my student id is {2}'.format('minseong kwon',25,201421094)
SyntaxError: unexpected indent
>>> a='My name is {0}. I am {1} years old and my student id is {2}'.format('minseong kwon',25,201421094) #형식을 갖춘 문자열을 만들 때 사용한다. 이때 문자열 안에 중괄호로 {} 다른 데이터가 들어갈 자리를
#만들어 주고 format() 함수를 호출할때 자리에 들어갈 데이터를 순서대로 넣어주면 된다
>>> a='My name is {0}. I am {1} years old and my student id is {2}'.format('minseong kwon',25,201421094) #형식을 갖춘 문자열을 만들 때 사용한다.
#이때 문자열 안에 중괄호로 {} 다른 데이터가 들어갈 자리를
#만들어 주고 format() 함수를 호출할때 자리에
#들어갈 데이터를 순서대로 넣어주면 된다
>>> a
'My name is minseong kwon. I am 25 years old and my student id is 201421094'
'My name is minseong kwon. I am 25 years old and my student id is 201421094' #정상적으로 출력됨 문자열은 ''로 묶어 주어야 한다.
>>> a='My name is {0}. I am {1} years old and my student id is {2}'.format(minseong kwon,25,201421094)
SyntaxError: invalid syntax
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment