CODE‎ > ‎Python‎ > ‎

修改hosts檔案

這是修改自己PC裡的hosts檔,多添加一筆IP的網址對應

#coding=utf8

import os

def add_gae_access():
    host_file_path = os.path.join(os.getenv('windir'), 'system32\drivers\etc\hosts')
    
    with file(host_file_path, 'ab') as f:
         f.write("%s#GAE access%s203.208.39.104  idehong.appspot.com" % (os.linesep, os.linesep))


if __name__ == '__main__' :
    add_gae_access()
Comments