回答編集履歴

2

追記

2017/11/17 12:17

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -79,3 +79,35 @@
79
79
  三重文字列でダブルクォートを用いている理由は、**ないです**。
80
80
 
81
81
  ダブルクォートでなければいけないと信じ込んでいた時期があったので、その名残です。
82
+
83
+
84
+
85
+ 追記:11/17
86
+
87
+ ---
88
+
89
+ たまたまPEPを眺めているときにこれに関する記述を見つけましたので、引用します。
90
+
91
+ [PEP 8 -- Style Guide for Python Code - String Quotes](https://www.python.org/dev/peps/pep-0008/#string-quotes)
92
+
93
+ > In Python, single quoted strings and double quoted strings are the same. This PEP does not make a recommendation for this. Pick a rule and stick to it. When a string contains single or double quote characters, however, use the other one to avoid backslashes in the string. It improves readability.
94
+
95
+
96
+
97
+ > For triple quoted strings, always use double quote characters to be consistent with the docstring convention in PEP 257.
98
+
99
+
100
+
101
+ - 基本的にはどちらでもよいが、統一すべき
102
+
103
+ - ただし、エスケープが求められる場合はその限りでない
104
+
105
+ - 三重引用符を用いるときは、docstringに倣ってダブルクオートを使う
106
+
107
+
108
+
109
+ ---
110
+
111
+ なお、こちらが日本語版です。あんまりいい翻訳だと思いませんが...
112
+
113
+ [PEP 8 -- Python コードのスタイルガイド - 文字列に含まれる引用符](https://pep8-ja.readthedocs.io/ja/latest/#id14)

1

修正

2017/11/17 12:17

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -68,7 +68,7 @@
68
68
 
69
69
  >>>
70
70
 
71
- >>> print("printf(\"%d\n\", 10);") # raw文字列使えないしんどい
71
+ >>> print("printf(\"%d\n\", 10);") # この場合raw文字列使えないしんどい
72
72
 
73
73
  printf("%d\n", 10);
74
74