可以有两种方法: 1.随机生成 首先安装 pip install fake-useragent import random from fake_useragent import UserAgent def gererateUserAgent(self): # ua = UserAgent() # headers = {'User-Agent': ua.random} # print(headers) lst=[] for i in range(10): ua = UserAgent() lst.