- 论坛徽章:
- 60
|
- [root@localhost ~]# cat t.txt
- dataSource_game_1025{
- gameServer.code="1025"
- gameServer.name="28服"
- url='jdbc:mysql://xx.xx.xx.xx:3306/war_s28'
- username = "xxxx"
- password = "xxxx"
- }
- [root@localhost ~]# python t.py
- dataSource_game_1026{
- gameServer.code="1026"
- gameServer.name="29服"
- url='jdbc:mysql://xx.xx.xx.xx:3306/war_s29'
- username = "xxxx"
- password = "xxxx"
- }
- dataSource_game_1027{
- gameServer.code="1027"
- gameServer.name="30服"
- url='jdbc:mysql://xx.xx.xx.xx:3306/war_s30'
- username = "xxxx"
- password = "xxxx"
- }
- dataSource_game_1028{
- gameServer.code="1028"
- gameServer.name="31服"
- url='jdbc:mysql://xx.xx.xx.xx:3306/war_s31'
- username = "xxxx"
- password = "xxxx"
- }
- dataSource_game_1029{
- gameServer.code="1029"
- gameServer.name="32服"
- url='jdbc:mysql://xx.xx.xx.xx:3306/war_s32'
- username = "xxxx"
- password = "xxxx"
- }
- dataSource_game_1030{
- gameServer.code="1030"
- gameServer.name="33服"
- url='jdbc:mysql://xx.xx.xx.xx:3306/war_s33'
- username = "xxxx"
- password = "xxxx"
- }
- [root@localhost ~]# cat t.py
- #!/usr/bin/python
- # coding: utf-8
- max = 5 # 累加多少次
- import re
- with open('t.txt','r') as f:
- fd = f.readlines()
- for n in range(1,max+1):
- for r in fd:
- data = re.findall(r'\d+',r)
- if data:
- mdata = r.split('/')
- if len(mdata) != 0 :
- mdata[-1] = re.sub(r'\d+',str(int(data[-1])+n),mdata[-1])
- print '/'.join(mdata).strip('\n')
- else:
- print re.sub(r'\d+',str(int(data[-1])+n),r).strip('\n')
- else:
- print r.strip('\n')
- print ''
- [root@localhost ~]#
复制代码 好多游戏运维啊,我勒个去... 啥公司啊? |
|