草庐IT

cursor-position

全部标签

python - 类型错误 : get_params() missing 1 required positional argument: 'self'

我正在尝试将scikit-learn包与python-3.4一起使用来进行网格搜索,fromsklearn.feature_extraction.textimportTfidfVectorizerfromsklearn.linear_model.logisticimportLogisticRegressionfromsklearn.pipelineimportPipelinefromsklearn.grid_searchimportGridSearchCVimportpandasaspdfromsklearn.cross_validationimporttrain_test_split

python - UnicodeEncodeError : 'ascii' codec can't encode character u'\u201c' in position 34: ordinal not in range(128)

我一直在开发一个从StackOverflow检索问题的程序。直到昨天程序运行良好,但从今天开始我收到错误"MessageFileNameLinePositionTracebackC:\Users\DPT\Desktop\questions.py13UnicodeEncodeError:'ascii'codeccan'tencodecharacteru'\u201c'inposition34:ordinalnotinrange(128)"目前正在显示问题,但我似乎无法将输出复制到新的文本文件中。importsyssys.path.append('.')importstackexchang

python - iloc 给 'IndexError: single positional indexer is out-of-bounds'

我正在尝试使用以下代码对一些信息进行编码以读入机器学习模型importnumpyasnpimportpandasaspdimportmatplotlib.pyplotaspyDataset=pd.read_csv('filename.csv',sep=',')X=Dataset.iloc[:,:-1].valuesY=Dataset.iloc[:,18].valuesfromsklearn.preprocessingimportLabelEncoder,OneHotEncoderlabelencoder_X=LabelEncoder()X[:,0]=labelencoder_X.fit

python - Python 中的 cursor.fetchall() 与 list(cursor)

这两种方法都返回查询返回项的列表,我是否在这里遗漏了什么,或者它们确实有相同的用法?在性能方面有什么不同吗? 最佳答案 如果您使用默认游标,MySQLdb.cursors.Cursor,整个结果集将存储在客户端(即在Python列表中)cursor.execute()完成时。因此,即使你使用forrowincursor:您不会减少内存占用。整个结果集已经存储在一个列表中(参见MySQLdb/cursors.py中的self._rows)。但是,如果您使用SSCursor或SSDictCursor:importMySQLdbimpor

python - UnicodeDecodeError : 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

在我的一台机器上,当我使用google应用程序引擎或django时出现错误。例如:app.yamlapplication:demas1252cversion:1runtime:pythonapi_version:1handlers:-url:/imagesstatic_dir:images-url:/cssstatic_dir:css-url:/jsstatic_dir:js-url:/.*script:demas1252c.pydemas1252c.pyimportcgiimportwsgiref.handlersfromgoogle.appengine.ext.webappimpo

python - UnicodeDecodeError : 'ascii' codec can't decode byte 0xc3 in position 23: ordinal not in range(128)

当我尝试连接它时,当字段包含“ñ”或“´”时,我会收到UnicodeDecodeError。如果包含“ñ”或“´”的字段是最后一个,我不会出错。#...nombre=fabricanombre=nombre.encode("utf-8")+'-'+sector.encode("utf-8")nombre=nombre.encode("utf-8")+'-'+unidad.encode("utf-8")#...returnnombre有什么想法吗?非常感谢! 最佳答案 您正在编码为UTF-8,然后重新-编码为UTF-8。Python只

Python:受 cursor.execute("SELECT ...) 影响的行数

如何访问受以下因素影响的行数:cursor.execute("SELECTCOUNT(*)fromresultwhereserver_state='2'ANDnameLIKE'"+digest+"_"+charset+"_%'") 最佳答案 尝试使用fetchone:cursor.execute("SELECTCOUNT(*)fromresultwhereserver_state='2'ANDnameLIKE'"+digest+"_"+charset+"_%'")result=cursor.fetchone()result将保存一个

python 3.2 UnicodeEncodeError : 'charmap' codec can't encode character '\u2013' in position 9629: character maps to <undefined>

我正在尝试制作一个从sqlite3数据库中获取数据的脚本,但我遇到了问题。数据库中的字段是文本类型,并且包含html格式的文本。见下文Yahoo!html{}.yshortcuts{border-bottom:none!important;}.ReadMsgBody{width:100%;}.ExternalClass{width:100%;}VälkommentillYahoo!Mail.Anslutaochdelagårsnabbtochenkeltochärtillgängligtöverallt.Detärlättsomenplättattkommaigång.1.Läggti

python - 类型错误 : worker() takes 0 positional arguments but 1 was given

这个问题在这里已经有了答案:TypeError:method()takes1positionalargumentbut2weregiven(11个回答)关闭5个月前。我正在尝试实现一个子类,但它会抛出错误:TypeError:worker()接受0个位置参数,但给出了1个classKeyStatisticCollection(DataDownloadUtilities.DataDownloadCollection):defGenerateAddressStrings(self):passdefworker():passdefDownloadProc(self):pass

python - 简单的留言簿 django : __init__() takes 1 positional argument but 2 were given

我是Django新手,正在尝试制作一个简单的留言簿应用程序来适应环境。我收到以下错误,但我找不到错误:异常值:_init_()接受1个位置参数,但给出了2个。fromdjango.dbimportmodelsfromdjango.contrib.auth.modelsimportUserfromdjango.contribimportadminclassBericht(models.Model):titel=models.CharField(max_length=50)auteur=models.ForeignKey(User,blank=True)email=models.Email