我接受来自命令行的4个参数,并希望使用它在python中创建文件。如何将命令行参数打印到文件
我的语法是:
def configuredhcp(self,**kwargs):
''' Get the input parameters '''
client_ip = kwargs.get('client_ip',None)
client_mask = kwargs.get('client_mask',None)
option_routers = kwargs.get('option_routers',None)
option_broadcast = kwargs.get('option_broadcast',None)
range_ip = kwargs.get('range_ip',None)
infile = open('dhcpconf.txt', 'r+')
infile.write("Subnet %s netmask %s " % (client_ip ,client_mask)
infile.write("option routers %s " % (option_routers)
infile.write("option broadcast-address %s; " % (option_broadcast)
infile.write(" range %s;" % (range_ip)
infile.close()
我得到了行语法错误
infile.write( “选项路由器%的” %(option_routers)
如果这是确切的代码,则没有匹配的右括号。 – Lafexlos