Python 3:AttributeError:“int"对象没有“选择"属性 [英] Python 3: AttributeError: 'int' object has no attribute 'choice'
本文介绍了Python 3:AttributeError:“int"对象没有“选择"属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试运行这个 python 3 程序,但它似乎无法运行超过第一个循环.
Trying to run this python 3 program but it seems it can't run past the first loop.
import webbrowser
import time
import random
while True:
sites = ['www.google.com', 'www.mastercode.com', 'www.youtube.com']
site = random.choice(sites)
visit = ("http://{}".format(site))
webbrowser.open(vist)
time.sleep(2)
在第一个循环后出现此错误:
After the 1st loop it gives this error:
AttributeError: 'int' 对象没有属性 'choice'
我无法修复它.我还是 Python 3 的新手.
I am unable to fix it.I am still new to python 3.
推荐答案
我想你一定有一个名为 random
的变量,我的意思是你已经覆盖了 python 的默认随机模块,改变了那个变量名从随机到其他东西.
I think you must have a variable called random
, I mean you had override the default random module of python, change that variable name from random to something else.
这篇关于Python 3:AttributeError:“int"对象没有“选择"属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文