Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tamago324/bde8d2f30f1bef53dce50f0b564d23e2 to your computer and use it in GitHub Desktop.
Save tamago324/bde8d2f30f1bef53dce50f0b564d23e2 to your computer and use it in GitHub Desktop.

https://github.com/XXXalice/internet_yakuza/tree/master/webdrive/sushi

をちらっと見たら、設定ファイルに設定値を書き出しておいて、それを読み込んでいたから、いいなって思ったからメモメモ

設定値を外部ファイルに書いておき、それを読むようにする
設定も簡単に書き換えられるし、いい感じ

設定ファイルのparam.ymlは以下のようになっている

driver:
  path: '/Users/umemiya/.rbenv/shims/chromedriver'
sushi:
  url: 'http://typingx0.net/sushida/play.html'

設定値の読み込み

with open('param.yml', 'r') as param:
    self.param_dict = yaml.load(param)
    
...
self.driver.get(self.param_dict['sushi']['url'])

こんな感じでできるのか!よさそう!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment