标签: attributeerror

AttributeError:“按钮”对象没有属性“设置”-tkinter

我收到一个错误:

self.button.set(str(self))
AttributeError: 'Button' object has no attribute 'set'
Run Code Online (Sandbox Code Playgroud)

我不知道要进行哪些更改才能使其正常工作。

这是代码的重要部分:

class Cell:
    def show_word(self):
            """ Shows the word behind the cell """
            if self.hidden == True:
                self.hidden = False
            else:
                self.hidden = True

            self.button.set(str(self))

class Memory(Frame):
    def create_widgets(self):
        """ Create widgets to display the Memory game """
        # instruction text
        Label(self,
              text = "- The Memory Game -",
              font = ("Helvetica", 12, "bold"),
              ).grid(row = 0, column = 0, columnspan = 7)

        # buttons to show the words
        column …
Run Code Online (Sandbox Code Playgroud)

tkinter attributeerror

1
推荐指数
1
解决办法
4909
查看次数

涉及"AttributeError:'NoneType'对象的奇怪错误没有属性'append'"

所以我试图解析一个文本文件,将其转换为一个列表并拆分空间列表中的每个项目.

我创建了一个测试变量来自己运行这部分代码.我在Spyder编辑器中的代码:

test = ['NC_009142.1_03_012_002_001 560', 'NC_017586.1_13_009_003_001 555', 'NC_016111.1_13_010_003_001 555']
ListOfLinesParsed = test

PN_List = []
counter_iterative = 0
while counter_iterative < len(ListOfLinesParsed):
    PN_List = PN_List.append(ListOfLinesParsed[counter_iterative].split()[0])
    counter_iterative += 1

print PN_List
Run Code Online (Sandbox Code Playgroud)

哪个返回错误:

runfile(r'/ home/jake/.spyder2/.temp.py',wdir = r'/ home/jake/.spyder2')

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/usr/lib/python2.7/dist-
packages/spyderlib/widgets/externalshell/sitecustomize.py", line 493, in runfile

    execfile(filename, namespace)
  File "/home/jake/.spyder2/.temp.py", line 7, in <module>

    PN_List = PN_List.append(ListOfLinesParsed[counter_iterative].split()[0])

AttributeError: 'NoneType' object has no attribute 'append'
Run Code Online (Sandbox Code Playgroud)

但是,如果我直接输入命令到终端我没有错误:

testL = []

testL.append(试验[0] .split()[0])

为test1 …

python attributeerror

1
推荐指数
1
解决办法
2160
查看次数

Python openpyxl 模块说:AttributeError: 'tuple' 对象没有属性 'upper'

安装了 Python 3.4 和模块jdcal以及openpyxl

尝试在openpyxl库上从 Python 读取和写入 XLSX 文件。我安装了jdcall模块和openpyxl模块。代码让我创建工作簿和工作表:

from openpyxl import Workbook
wb  = Workbook()
ws  = wb.active
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试像这样写入第一个单元格:

ws[ 1, 1]   = 'testing 1-2-3'
Run Code Online (Sandbox Code Playgroud)

Python 说:

C:\Wolf\Python Studies>database.py
Traceback (most recent call last):
 File "C:\Wolf\Python Studies\database.py", line 13, in <module>
   ws[ 1, 1]   = 'testing 1-2-3'
 File "C:\Python34\lib\site-packages\openpyxl-2.2.0b1-py3.4.egg\openpyxl\worksheet\worksheet.py", line 403, in __setitem__
   self[key].value = value
 File "C:\Python34\lib\site-packages\openpyxl-2.2.0b1-py3.4.egg\openpyxl\worksheet\worksheet.py", line 400, in __getitem__ <BR>
   return self._get_cell(key)
 File "C:\Python34\lib\site-packages\openpyxl-2.2.0b1-py3.4.egg\openpyxl\worksheet\worksheet.py", line 368, …
Run Code Online (Sandbox Code Playgroud)

python tuples export-to-excel attributeerror openpyxl

1
推荐指数
1
解决办法
1万
查看次数

AttributeError:'module'对象没有属性'hist'

我是Python的新手(我正在使用Spyder)并且正在尝试创建一些直方图,这些直方图来自IMDB的顶级电影.我已经导入了matplotlib,numpy和pandas,以及.txt文件,但是当我运行以下代码行时:

plt.hist(data.year, bins=np.arange(1950, 2013), color='#cccccc')
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息:

Traceback (most recent call last):
  File "stdin", line 1, in <module>
AttributeError: 'module' object has no attribute 'hist'
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

python matplotlib histogram attributeerror pandas

1
推荐指数
1
解决办法
8891
查看次数

如何忽略AttributeError:'NoneType'

location = geolocator.geocode(" ".join(address.values()))
if location.longitude is not None:
    node['pos'] = [location.longitude, location.latitude]
Run Code Online (Sandbox Code Playgroud)

不明白的方式我仍然得到这个错误:

  File "/home/easypc/Documents/Udacity_nano_degree/Data_Wrangling/audit_vilnius.py", line 167, in shape_element
    if location.longitude is not None:
AttributeError: 'NoneType' object has no attribute 'longitude'
Run Code Online (Sandbox Code Playgroud)

python attributeerror geopy nonetype

1
推荐指数
1
解决办法
6761
查看次数

python错误:“ str”对象没有属性“ upper()”

我发现在Python 3中使用.format()方法进行字符串格式化的可能性,但是我提出了一个我不理解的错误。

因此,为什么以下行可以[让我认为可以完全像传递给format()的参数那样使用“ 0”]:

s = 'First letter of {0} is {0[0]}'.format("hello")  
#gives as expected: 'First letter of hello is h'
Run Code Online (Sandbox Code Playgroud)

但这不是[在{0}中将方法或函数应用于0无效吗?]:

s = '{0} becomes {0.upper()} with .upper() method'.format("hello")
Run Code Online (Sandbox Code Playgroud)

引发以下错误:

AttributeError: 'str' object has no attribute 'upper()'
Run Code Online (Sandbox Code Playgroud)

为什么引发的错误说明我已将upper用作属性而不是方法?还有另一种方法可以做到:

s = '{} becomes {} with .upper() method'.format("hello","hello".upper())
#gives as expected: 'hello becomes HELLO with .upper() method'
Run Code Online (Sandbox Code Playgroud)

谢谢!

python formatting attributeerror python-3.x

1
推荐指数
1
解决办法
3959
查看次数

Folium - 模块“folium”没有属性“Map”

我只是想运行标准:

import folium
   map_osm = folium.Map(location=[45.5236, -122.6750])
   map_osm.create_map(path='osm.html')
Run Code Online (Sandbox Code Playgroud)

我得到:

AttributeError: module 'folium' has no attribute 'Map'
Run Code Online (Sandbox Code Playgroud)

我正在使用 Anaconda 3 / spyder。检查并安装了folium、vincent、jinja2、pandas。

可能是什么问题呢?

python attributeerror folium

1
推荐指数
1
解决办法
7011
查看次数

Python 3.5.2、openpyxl v 2.4.1、get_highest_row()、AttributeError

我是 Python 新手,但在打开带有openpyxlModule的 Excel 文件时遇到问题。我在 Windowsopenpyxl上运行V2.4.1。Python 3.5.2这是我代码的一小部分。我收到以下错误。

这是我得到的错误:

在此处输入图片说明

请帮我解决这个问题,找到一种方法来获得工作表中的最大行数和列数。

如果我必须更改我的openpyxl模块版本,请描述!

提前致谢。

WorkBook = openpyxl.load_workbook("G:\\Python_Created\\DS.xlsx")
#I have a Sheet named "Original" in my Excell Workbook
Sheet = WorkBook.get_sheet_by_name("Original")
Sheet.get_highest_row()
Run Code Online (Sandbox Code Playgroud)

attributeerror python-3.x openpyxl

1
推荐指数
1
解决办法
6683
查看次数

Tensorflow rnn:未定义名称"seq2seq"

我正在尝试这个笔记本:https: //github.com/sjchoi86/Tensorflow-101/blob/master/notebooks/char_rnn_sample_tutorial.ipynb

我对[6]中的这一行有疑问:

outputs, final_state = seq2seq.rnn_decoder(inputs, istate, cell, loop_function=None, scope='rnnlm')
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

NameError: name 'seq2seq' is not defined
Run Code Online (Sandbox Code Playgroud)

我正在使用tensorflow 1.0.1.我试过了

tf.contrib.seq2seq
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

AttributeError: 'module' object has no attribute 'rnn_decoder'
Run Code Online (Sandbox Code Playgroud)

我认为在tensorflow 1.0.1中新的rnn网络实现是一个问题,但我不知道如何修复它.

python attributeerror lstm tensorflow recurrent-neural-network

1
推荐指数
1
解决办法
1353
查看次数

AttributeError:模块'datetime'没有属性'time'

我正在使用Python 3.7并尝试datetime从库中学习模块,但是我正在获取AttributeError。下面的代码:

import datetime

t = datetime.time(4, 20, 1)

# Let's show the different components
print(t)
print('hour  :', t.hour)
print('minute:', t.minute)
print('second:', t.second)
print('microsecond:', t.microsecond)
print('tzinfo:', t.tzinfo)
Run Code Online (Sandbox Code Playgroud)

作为运行文件,我得到此错误 AttributeError: module 'datetime' has no attribute 'time'

请帮助我找到我要去的地方。谢谢

python runtime-error attributeerror python-3.x python-datetime

1
推荐指数
1
解决办法
663
查看次数