用python实现带参数的脚本(修改hosts文件)
from os import path from sys import argv from getopt import getopt path=path.join("C:\Windows\System32\drivers\etc\hosts") #打开hosts文件 opt,args=getopt(argv[1:]) #在文件后面跟上参数 content="\n%s %s"%(args[0],args[1]) #拼接内容 with open(path,'a') as file: file.write(content) #往hosts文件里面添加内容
相关推荐
yuzhongdelei0 2019-12-31
学习备忘录 2019-12-16
89540596 2019-11-18
Wonder的学习 2019-11-18
invokerzhang 2019-11-10
chinademon 2019-04-02
89291642 2011-03-05
dazhi00 2019-06-21
别时茫茫 2011-05-19
heyiaiqing 2018-07-21
rookieliang 2010-03-10
生物信息学 2018-02-01
chongtianfeiyu 2018-01-24
Pythonandme 2017-12-29
83443560 2019-04-29
lzujiangge 2017-01-17
liushuibufuqin 2015-01-02
Python探路者 2019-04-26