LoginSignup
30
24

More than 5 years have passed since last update.

Python のヒアドキュメントを見やすくする小技

Posted at

Python では通常、ヒアドキュメントを次のように書きます。

Python
message = """Humpty Dumpty sat on a wall,
Humpty Dumpty had a great fall.
All the king's horses and all the king's men
Couldn't put Humpty together again."""

しかし、ちょっと見にくいと思いませんか?
こうすれば見やすくなります。

Python
message = """
Humpty Dumpty sat on a wall,
Humpty Dumpty had a great fall.
All the king's horses and all the king's men
Couldn't put Humpty together again.
"""[1:-1]

ちょっとした小技でした。

30
24
1

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
30
24