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

Update 문자열 메소드.txt 추가 주석 설명

parent 66e6230f
Branches
No related tags found
No related merge requests found
......@@ -5,7 +5,8 @@ Type "help", "copyright", "credits" or "license()" for more information.
>>>
>>> a="Good afternoon"
>>> 'good' in a
False
False #false와 true 에는 따옴표가 붙지 않는다.
>>> 'Good' in a
True
>>> 'af'in a
......@@ -13,7 +14,7 @@ True
>>> 'oon'in a
True
>>>
>>> a.startswith('G)
>>> a.startswith('G) #원본 문자열이 매개변수로 입력한 문자열로 시작하는 판단하는 함수
SyntaxError: EOL while scanning string literal
>>> a.startswith('G')
......@@ -25,13 +26,13 @@ True
>>> a.startswith("Good")
True
>>> a.endswith("llo")
>>> a.endswith("llo") # 원본 문자열이 매개변수로 입력한 문자열로 끝나는지를 판단한다. 결과는 true or false
False
>>> a.endswith("noon")
True
>>> a.find('G')
>>> a.find('G') #find 원본 문자열 안에 매개변수로 입력한 문자열이 존재하는 위치를 앞에서 부터 찾는다.
0
>>> a.find("ter")
......@@ -58,7 +59,7 @@ True
>>> '123'.isalnum()
True
>>> '123 abc'.isalnum()
>>> '123 abc'.isalnum() //. 이나 특수문자는 알파벳과 숫자가 아니다.
False
>>> "123abc...".isalnum()
......@@ -124,7 +125,8 @@ 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)
>>> a='My name is {0}. I am {1} years old and my student id is {2}'.format('minseong kwon',25,201421094) #형식을 갖춘 문자열을 만들 때 사용한다. 이때 문자열 안에 중괄호로 {} 다른 데이터가 들어갈 자리를
#만들어 주고 format() 함수를 호출할때 자리에 들어갈 데이터를 순서대로 넣어주면 된다
>>> a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment