LoginSignup
0
0

More than 5 years have passed since last update.

OS判別とPythonと私

Posted at

(※割とどうでもいい)

 tensorflowのチュートリアルで、こんな行を見つけたんだけど、どっからどう見てもposix
 Windowsで開発するんだけど、この書き方でいいのかなーみたいに悩んで、結局、posixでもWindowsでも動く書き方にした

※修正前

tf.gfile.MakeDirs("/tmp/XXX")  // XXXは何でも

※修正後

if os.name == 'nt': tmp_dir = "~\\AppData\\Local\\Temp\\census_data" // Windowsの場合
else: tmp_dir = "/tmp/census_data"  // posixの場合

tf.gfile.MakeDirs(tmp_dir)

もっとエレガントな書き方があるかも

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