草庐IT

style-attribute

全部标签

python - Pandas 错误 : 'DataFrame' object has no attribute 'loc'

我是pandas的新手,正在尝试Pandas0.10.1版的Pandas10分钟教程。但是,当我执行以下操作时,出现如下所示的错误。printdf工作正常。为什么.loc不起作用?代码importnumpyasnpimportpandasaspddf=pd.DataFrame(np.random.randn(6,4),index=pd.date_range('20130101',periods=6),columns=['A','B','C','D'])df.loc[:,['A','B']]错误:AttributeErrorTraceback(mostrecentcalllast)in(

美丽的汤输出{{model.attribute}}代替普通文本

我的机器:项目清单Ubuntu16.04。Python3.5.2。BS44.6.0。LXML3.8.0。我想解析Tokopedia网站。这是我的代码:tokopedia_link='https://www.tokopedia.com/search?st=product&q=baju+baru'req=urllib.request.Request(tokopedia_link)req.add_header('User-agent','Mozilla5.10')withurllib.request.urlopen(req)asresponse:the_page=response.read()sou

python - Web.py - 属性错误 : 'module' object has no attribute 'application'

我使用web.py编写了一个小的helloworld站点,但是当我运行pythoncode.py时,我收到一条错误消息:Traceback(mostrecentcalllast):File"E:\Python25\webpy\web\mysite.py",line1,inimportwebFile"E:\Python25\webpy\web\web.py",line4,inapp=web.application(urls,globals())AttributeError:'module'objecthasnoattribute'application'这是我的代码(从web.py的教程

python - 属性错误 : module 'mysql' has no attribute 'connector'

我正在运行Ubuntu16.04,尝试在python中连接到mysql:importmysqlusername='root'cnx=mysql.connector.connect(user=username,database='db')cnx.close()但是我得到一个错误:File"pysql1.py",line4,incnx=mysql.connector.connect(user=username,database='db')AttributeError:module'mysql'hasnoattribute'connector'我通过下载包安装了mysqlpython模块he

python - numpy 属性错误 : with theano module 'numpy.core.multiarray' has no attribute _get_ndarray_c_version

我正在运行这个简单的例子:importtheanox=theano.tensor.dscalar()f=theano.function([x],2*x)f(4)我得到:AttributeError:('Thefollowingerrorhappenedwhilecompilingthenode',Elemwise{mul,no_inplace}(TensorConstant{2.0},),'\n',"module'numpy.core.multiarray'hasnoattribute'_get_ndarray_c_version'")我认为这一定是一个numpy错误,所以我尝试更新,

Python pandas : pd. options.display.mpl_style = 'default' 导致图形崩溃

一切都在标题中。如果我没有在我的python脚本的开头设置此选项,我的图表会正确显示,否则它会打开图表窗口但直接关闭它并结束运行。我使用的是pandas0.14.0和matplotlib1.3.0。有人看过吗?如果需要,您可以在下面查看我的代码。importnumpyasnpimportpandasaspdimportmatplotlib.pyplotasplt#pd.options.display.mpl_style='default'df=pd.DataFrame(np.random.randn(1000,4),index=pd.date_range('1/1/2000',peri

创建word文档时python-docx style_id错误

我正在学习python-docx上提供的教程站点以创建MS-Word文档,但出现错误:M:\Sites>pythonword.pyC:\ProgramFiles\IBM\SPSS\Statistics\22\Python\lib\site-packages\docx\styles\styles.py:54:UserWarning:stylelookupbystyle_idisdeprecated.Usestylenameaskeyinstead.warn(msg,UserWarning)单词.pyfromdocximportDocumentfromdocx.sharedimportIn

python - Werkzeug 属性错误 : 'module' object has no attribute 'InteractiveInterpreter'

尝试使用app.run(debug=True)运行代码时,使用Flask(0.8)和Werkzeug(0.8.1)我收到下面描述的错误。使用app.run()时没有报错错误Traceback(mostrecentcalllast):File"code2.py",line9,inapp.run(debug=True)File"//env/lib/python2.7/site-packages/Flask-0.8-py2.7.egg/flask/app.py",line703,inrunrun_simple(host,port,self,**options)File"//env/lib/p

python - PEP 0008 : What does the BDFL mean by 'in true XP style' ?

我正在阅读PEP0008(thepythonstyleguide),并遇到以下原因不遵循风格指南中的任何规则。它说打破规则是可以的beconsistentwithsurroundingcodethatalsobreaksit(maybeforhistoricreasons)--althoughthisisalsoanopportunitytocleanupsomeoneelse'smess(intrueXPstyle).“真正的XP风格”是什么意思? 最佳答案 评论中提到,这里的XP是指ExtremeProgramming.我认为评

python - Django 应用引擎 : AttributeError: 'AnonymousUser' object has no attribute 'backend'

我正在使用djangoappengine。当我尝试创建新用户、对该用户进行身份验证并让他们登录时,出现以下错误AttributeError:'AnonymousUser'objecthasnoattribute'backend'。我的代码很简单,看起来像:user=User.objects.create_user(username,username,password)user.set_password(password)user.save()user=django.contrib.auth.authenticate(username=username,password=password