"Python 문자열 여러 줄 입력"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 2개는 보이지 않습니다)
3번째 줄: 3번째 줄:
;Python 멀티라인 문자열
;Python 멀티라인 문자열


<source lang='python'>
<syntaxhighlight lang='python'>
s = '''Hello,
s = '''Hello,
How are you?'''
How are you?'''
9번째 줄: 9번째 줄:
# Hello,
# Hello,
# How are you?
# How are you?
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
s = '''Hi,
What's up?'''
print( s )
# Hi,
# What's up?
</syntaxhighlight>
<syntaxhighlight lang='python'>
s = """Hi,
s = """Hi,
What's up?"""
What's up?"""
16번째 줄: 23번째 줄:
# Hi,
# Hi,
# What's up?
# What's up?
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
print """Hello
print """Hello
My
My
Friend"""
Friend"""
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
print """\
print """\
Hello
Hello
My
My
Friend"""
Friend"""
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
34번째 줄: 41번째 줄:


[[분류: Python]]
[[분류: Python]]
[[분류: 멀티라인]]

2023년 1월 20일 (금) 14:55 기준 최신판

1 개요[ | ]

Python 문자열 여러 줄 입력
Python 멀티라인 문자열
s = '''Hello,
How are you?'''
print( s )
# Hello,
# How are you?
s = '''Hi,
What's up?'''
print( s )
# Hi,
# What's up?
s = """Hi,
What's up?"""
print( s )
# Hi,
# What's up?
print """Hello
My
Friend"""
print """\
Hello
My
Friend"""

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}