回答編集履歴

1

違いを追記

2022/09/25 13:19

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -1,5 +1,13 @@
1
1
  raw文字列を使いましょう。
2
2
  あるいは、Pythonの中ではディレクトリ区切りに `/` を使うといいですよ。
3
+
4
+ ```py
5
+ >>> "C:\Users\ikate\Documents\my test\pi_digits.text"
6
+ File "<stdin>", line 1
7
+ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
8
+ >>> r"C:\Users\ikate\Documents\my test\pi_digits.text"
9
+ 'C:\\Users\\ikate\\Documents\\my test\\pi_digits.text'
10
+ ```
3
11
 
4
12
  ```py
5
13
  with open(r"C:\Users\ikate\Documents\my test\pi_digits.text") as file_object: