我试图打开相同的所需网页(由用户)选定的次数,但我似乎无法让它工作。#Imports modulesimport requestsimport time#Assigning variables to stringsimport urllib.requesturl = "https://r6tab.com/bd6a3f35-5060-499a-8645-369664aae1d9"# Open the URL as Browser, not as python urllibhow = input("Enter how many views you want!")for counter in range (0,how): page=urllib.request.Request(url,headers={'User-Agent': 'Mozilla/5.0'}) infile=urllib.request.urlopen(page).read()Traceback (most recent call last): File "C:/Users/lauchlan/Desktop/sss.py", line 14, in <module> for counter in range (0,how):TypeError: 'str' object cannot be interpreted as an integer>>> 修复了错误,但网页上的浏览量没有计算在内
2 回答
哈士奇WWW
TA贡献1799条经验 获得超6个赞
input
返回一个字符串。您需要转换为整数才能在range
. 尝试:how = int(input("Enter how many views you want!"))
添加回答
举报
0/150
提交
取消