0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Pythonチュートリアルで学ぶ:文字列

Posted at

Pythonの基礎的な勉強をしています。
文字列操作について学んだことを備忘録代わりに書きます。

「\」(バックスラッシュ)でエスケープ処理ができます。

strPrint = '"Isn\'t," they said.'

print(strPrint)

実行結果はこちらです。

image.png

また、「\n」で改行ができます。

s = 'One \nTwo'
print(s)

実行結果はこちらです。
image.png

最後に、文字列の前に「r」をつけると「\n」が文字列とみなされます。

print('D:\python\namefile')

print(r'D:\python\namefile')

実行結果は以下です。
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?