美文网首页
IPython 读取USER_AGENT数据统计操作系统

IPython 读取USER_AGENT数据统计操作系统

作者: 绍重先 | 来源:发表于2018-01-26 16:04 被阅读0次
user_devices = [rec['a'] for rec in records if 'a' in rec]

# <codecell>

def device_counts(seq):
    counts = {}
    devices = {'Windows','compatible','iPhone','iPad','BlackBerry','Macintosh','Linux'}
    for name in devices:
        counts[name] = 0
    
    for x in seq:
        for name in devices:
            if name in x:
                counts[name]+=1
    return counts
        
            
            

# <codecell>

acounts = device_counts(user_devices)

相关文章

网友评论

      本文标题:IPython 读取USER_AGENT数据统计操作系统

      本文链接:https://www.haomeiwen.com/subject/ljlwaxtx.html