4
7

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 5 years have passed since last update.

pythonでファイルパスを表記する方法

Last updated at Posted at 2019-01-28

#pythonでファイルパスを書く場合のメモ書き

Pythonでバックスラッシュ(¥)を扱う場合のいくつかの方法。

##エスケープシーケンスを使う

バックスラッシュを付ける
filepath = "C:\\user\\joji\\Desktop\\hoge.txt"

##生(raw data)データ指定する。

先頭にrを付ける
filepath = r"C:\user\joji\Desktop\hoge.txt"

rって生って意味だったんですねー。

4
7
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
4
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?