草庐IT

pg_attribute

全部标签

python - 获取属性错误 : 'map' object has no attribute 'sort'

我正在尝试按递增顺序对数组进行排序。但是代码出现以下错误:a=[]a=map(int,input().split(''))a.sort()print(a)帮帮我...ERROR:AttributeError:'map'objecthasnoattribute'sort' 最佳答案 在python3中,map不返回列表。相反,它返回一个迭代器对象,并且由于sort是list对象的一个​​属性,您会收到一个属性错误。如果要对结果进行就地排序,需要先将其转换为列表(不推荐)。a=list(map(int,input().split('')

python - 属性错误 : 'list' object has no attribute 'replace' when trying to remove character

我正在尝试通过执行以下操作从我的字符串中删除字符'kickoff=tree.xpath('//*[@id="page"]/div[1]/div/main/div/article/div/div[1]/section[2]/p[1]/b[1]/text()')kickoff=kickoff.replace("'","")这给了我错误AttributeError:'list'objecthasnoattribute'replace'我有php背景,我不确定这样做的正确方法是什么? 最佳答案 xpath方法返回一个列表,你需要迭代项目。k

python - 类型错误 : 'generator' object has no attribute '__getitem__'

我写了一个应该返回字典的生成函数。但是,当我尝试打印一个字段时,出现以下错误printrow2['SearchDate']TypeError:'generator'objecthasnoattribute'__getitem__'这是我的代码fromcsvimportDictReaderimportpandasaspdimportnumpyasnpdefgenSearch(SearchInfo):forrow2inDictReader(open(SearchInfo)):yieldrow2train='minitrain.csv'SearchInfo='SearchInfo.csv'r

python - 属性错误 : 'Graph' object has no attribute 'cypher' in migration of data from Postgress to Neo4j(Graph Database)

我正在手动将数据从postgres迁移到图形数据库。我写了下面的脚本:importpsycopg2frompy2neoimportauthenticate,Graphauthenticate("localhost:7474","neo4j","password")n4j_graph=Graph("http://localhost:7474/db/data/")try:conn=psycopg2.connect("dbname='db_name'user='user'password='password'")except:print"goodbye"cur=conn.cursor()tr

python - 属性错误 : 'str' object has no attribute 'fileno'

代码:importsubprocessdefprintit():foriinrange(6):forjinrange(6):query="selectrxpkts,txpktsfrom./log.csvwheredatapath="+str(i)+"andport="+str(j)fileName=str(i)+"_"+str(j)+".csv"withopen(fileName,"w+"):p=subprocess.Popen(["python","q","-H","-d",",",query],stdout=fileName)printit()错误:$pythonprocessLo

python - 属性错误 : 'Ui_MainWindow' object has no attribute 'setCentralWidget'

我仍在为我的数据库开发GUI,现在我有一个不同的错误:Traceback(mostrecentcalllast):File"G:\Python\DatabaseKastThuis\PyQtTest\MainMenu_ui.py",line84,inex=Ui_MainWindow()File"G:\Python\DatabaseKastThuis\PyQtTest\MainMenu_ui.py",line16,in__init__self.setupUi(self)File"G:\Python\DatabaseKastThuis\PyQtTest\MainMenu_ui.py",lin

python 2 : AttributeError: 'list' object has no attribute 'strip'

我有一个关于列表的小问题。所以我有一个名为l的列表:l=['Facebook;Google+;MySpace','Apple;Android']如您所见,我的列表中只有2个字符串。我想用';'分隔列表l并将新的5个字符串放入名为l1的新列表中。我该怎么做?我也试过这样做:l1=l.strip().split(';')但是Python给我一个错误:AttributeError:'list'objecthasnoattribute'strip'如果“list”对象没有属性“strip”或“split”,我该如何拆分列表?谢谢 最佳答案

python - SQLAlchemy , 属性错误 : 'tuple' object has no attribute 'foreign_keys'

我有以下模型来描述我的数据库模式:fromsqlalchemy.ext.declarativeimportdeclarative_basefromsqlalchemyimportColumn,Integer,String,ForeignKeyfromsqlalchemy.ormimportrelationship,backrefimportsqlalchemy.dialects.mysqlasmysqlBase=declarative_base()classCountry(Base):__tablename__='countries'__table_args__={'mysql_eng

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

我正在尝试使用WebSocketApp通过python连接到API,但我似乎无法做到这一点。无论我尝试什么,我都会不断收到此错误:AttributeError:'module'对象没有属性'WebSocketApp'这是我使用的简单代码importwebsocketimportjsondefon_open(ws):json_data=json.dumps({'data':'value'})ws.send(json_data)defon_message(ws,message):print('dataupdate:%s'%message)if__name__=="__main__":api

python - 获取 AttributeError : <class> has no attribute <method>

我正在模块mod1的类中创建一个方法,并按如下方式调用它:classblahblah:deffoobar(self,bvar,**dvar)////returndvar并将其称为:obj1=mod1.blahblah()dvar1=obj1.foobar(True,**somedictionary)它抛出一个Attributeerror:blahblahhasnoattributenamedfoobar你能帮我解决一下吗?提前致谢 最佳答案 您描述的错误类型可能仅仅是由于缩进不匹配引起的。如果该方法位于类(class)的最底部,请将