9.3 연습문제
-
6. 문자열 사용하기Python/Grammar 2022. 11. 30. 13:07
#1. 문자열 사용하기 1-1. 작은따옴표 한개씩으로 묶어 문자열 만들기 : 문자열 안에 큰 따옴표를 사용하고 싶은 경우 작은따옴표로 묶인 문자열 안에서 작은따옴표를 단독으로 사용할 수 없다. 작은따옴표로 묶었을 때 작은따옴표를 문자열 안에 포함시키고 싶다면 \'와 같이 역슬래쉬 뒤에 작은 따옴표를 붙여서 사용한다. 큰 따옴표 안에 큰 따옴표를 사용하고 싶을 때도 마찬가지이다. 문자열로 된 변수를 표현할 경우에도 작은따옴표를 사용한다. >>> 'Python isn\'t difficult' "Python isn't difficult" 1-2. 큰따옴표 한개씩으로 묶어 문자열 만들기 문자열 안에 작은 따옴표를 사용하고 싶은 경우 문장을 표현할 경우 >>> s = "Python isn't difficult" ..