首先安装相关的库 pip install fake-useragent 然后使用该库 from fake_useragent import UserAgent ua = UserAgent() ua.ie Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US); ua.msie Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.