왼쪽에서 문자열을 공백으로 씁니다.파이썬 3에서 문자열에서 ''를 찾는 방법
def main():
str_strip = input('enter a string of which whitespace are stripped: ')
cs-strip(str_strip)
def cs-strip(str_strip):
i = 0
temp = list(str_strip)
if temp[0] == ' ':
temp.remove(temp[0])
elif temp[0] == '\' :
if temp[1] == 'n' or temp[1] == 't':
temp.remove(temp[0])
temp.remove(temp[0])
new = ''.join(map(str,temp))
print(new)
main()
하지만 캔트 견적 비교 '\'다른 문자열을, 나는 '' '', 그것은 여전히 작동하지 않는 '\'노력했다. 문자열에 '\'가 포함되어 있거나 포함되어 있으면 어떻게 문자열을 비교할 수 있습니까?
힌트 : 귀하의 질문에 구문 강조 봐. – ApproachingDarknessFish
'\'문자로'\'문자를 이스케이프해야합니다. 'temp [0] =='\\ '' –
구문에 "닫는 인용 부호 [']"가 없습니다. 도움이되지 않습니다. – Byron