1 from user_agents import parse 2 3 uastr = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safari/537.36 SE 2.X MetaSr 1.0" 4 5 ua = parse(uastr) 6 print(ua, type(ua)) 7 print(ua.browser) 8 print(ua.browser.version, type(ua.browser.version)) 9 print(ua.browser.version_string, type(ua.browser.version_string)) 10 11 # PC / Windows 8.1 / Sogou Explorer 1.0 <class 'user_agents.parsers.UserAgent'> 12 # Browser(family='Sogou Explorer', version=(1, 0), version_string='1.0') 13 # (1, 0) <class 'tuple'> 14 # 1.0 <class 'str'>