|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#!/usr/bin/env python3
import sys
import csv
class Args():
def __init__(self):
self.args = sys.argv[1:]
#print(self.args)
index = self.args.index('-c')
self.configfile = self.args[index+1]
#print(self.configfile)
index = self.args.index('-d')
self.userfile = self.args[index+1]
index = self.args.index('-o')
self.gongzifile = self.args[index+1]
print(self.gongzifile)
args1 = Args()
class Config(object):
def __init__(self):
print(8888)
self.config = self._read_config()
def _read_config(self):
config = {'s',0}
with open(args1.configfile) as f1:
for line in f1.readline():
print(line)
m = line.split('=')
print(m)
config = Config()
我想读取 某个目录下 test.cfg 文件的内容 但是这段代码编译后显示不对 配置文件格式是 100:3000
- #!/usr/bin/env python3
- import sys
- import csv
- class Args():
- def __init__(self):
-
- self.args = sys.argv[1:]
- #print(self.args)
- index = self.args.index('-c')
- self.configfile = self.args[index+1]
- #print(self.configfile)
- index = self.args.index('-d')
- self.userfile = self.args[index+1]
- index = self.args.index('-o')
- self.gongzifile = self.args[index+1]
- print(self.gongzifile)
-
-
-
- args1 = Args()
- class Config(object):
- def __init__(self):
- print(8888)
- self.config = self._read_config()
- def _read_config(self):
- config = {'s',0}
- with open(args1.configfile) as f1:
-
- for line in f1.readline():
- print(line)
- m = line.split('=')
- print(m)
- config = Config()
- config.config()
复制代码
你好像根本就没有获取嘛。
|
|