使用python提取日志里面的role_id、vip字段的值
使用python提取日志里面的role_id、vip字段的值,(vip字段可能为空或者缺失,此时需要给默认值0)日志样例:
1068 1529597015396 g60-database-380.i.nease.net /home/g60/gamedata/log/g60_GameStatistic_20180622.log 380_game02 G60_GameStatistic 1529596878_35 ,{"merc_capacity":2739,"cur_level":70,"account_id":"aebfr2ualeolqplc@ad.netease.win.163.com","type_id":307,"udid":"66e0b0278fbef358","ip":"101.90.127.224","role_sex":1,"app_channel":"netease","server":"380","role_occ":4,"role_id":"698382","vip":6,"pre_level":69,"guid":6882678726665895936,"role_level":80}
a = '1068 1529597015396 g60-database-380.i.nease.net /home/g60/gamedata/log/g60_GameStatistic_20180622.log 380_game02 G60_GameStatistic 1529596878_35 ,{"merc_capacity":2739,"cur_level":70,"account_id":"aebfr2ualeolqplc@ad.netease.win.163.com","type_id":307,"udid":"66e0b0278fbef358","ip":"101.90.127.224","role_sex":1,"app_channel":"netease","server":"380","role_occ":4,"role_id":"698382","vip":6,"pre_level":69,"guid":6882678726665895936,"role_level":80}'
dict_a = eval(a)
role_id = dict_a['role_id']
vip = dict_a['vip']
if not vip:
vip = 0
print(role_id,vip) 逃兵 发表于 2021-3-4 15:45
谢谢~
页:
[1]