草庐IT

sequence_length

全部标签

python - docstring max line-length 是否与正常的 PEP8 标准不同?

所以我查看了一些代码,并在pylint的帮助下将其提升到PEP8标准,我注意到如果我在打印语句中使用三引号,其中文本超过120个字符(我们允许120而不是79)pylint没有提示。这是pylint中的一个错误吗?三重引号中的字符串,因为您可能希望以这种方式格式化它们?为清楚起见:是的,pylint在所有其他超过行长度的情况下正常工作。 最佳答案 经常使用pylint,我也注意到了这种不一致。在MaximumLineLengthsectionofPEP8,它说:Therefore,pleaselimitalllinestoamaxi

python - 皮林特警告 : Possible unbalanced tuple unpacking with sequence

我有一段Python代码:deffunc1():a=set()b=','.join(map(str,list(a)))returnb,[]deffunc2():d=1e=2returnfunc1()+(d,e,)defmain():a,b,c,d=func2()if__name__=='__main__':main()当我通过pylint(1.4.0)运行它时,我收到警告:W:12,4:Possibleunbalancedtupleunpackingwithsequence:leftsidehas4label(s),rightsidehas3value(s)(unbalanced-tu

python - "use\G in negative variable-length lookbehinds to limit how far back the lookbehind goes"示例

在令人敬畏的正则表达式模块(https://pypi.python.org/pypi/regex)的pypi页面中指出\G可以“在负的可变长度后视中使用以限制后视的距离”。非常有趣,但该页面没有给出任何示例,当我尝试想象一个时,我的白带regex-fu简直令人窒息。谁能描述一些示例用例? 最佳答案 这是一个使用\G的例子和创造性的消极回顾:regex.match(r'\b\w+\b(?:\s(\w+\b)(?words应该是由单个空格分隔的字母数字字符串,例如"abcdeabbcd".该模式将匹配一系列独特的单词。\w+-匹配第一个

python - 结构错误 : unpack requires a string argument of length 16

处理PDF时file(2.pdf)使用pdfminer(pdf2txt.py)我收到以下错误:pdf2txt.py2.pdfTraceback(mostrecentcalllast):File"/usr/local/bin/pdf2txt.py",line115,inif__name__=='__main__':sys.exit(main(sys.argv))File"/usr/local/bin/pdf2txt.py",line109,inmaininterpreter.process_page(page)File"/usr/local/lib/python2.7/dist-pack

python - 类型错误 : sparse matrix length is ambiguous; use getnnz() or shape[0] while using RF classifier?

我正在学习scikitlearn中的随机森林,作为一个例子,我想使用随机森林分类器进行文本分类,使用我自己的数据集。所以首先我用tfidf对文本进行矢量化并进行分类:fromsklearn.ensembleimportRandomForestClassifierclassifier=RandomForestClassifier(n_estimators=10)classifier.fit(X_train,y_train)prediction=classifier.predict(X_test)当我运行分类时,我得到了这个:TypeError:Asparsematrixwaspassed

python - 用mechanize提交表单(TypeError : ListControl, must set a sequence)

我正在尝试使用mechanize提交表单但遇到错误(TypeError:ListControl,必须设置序列)在谷歌搜索了一段时间并尝试了几种不同的解决方案后我无法解决问题。我正在尝试提交所有字段。通过mechanize获取的表单数据(forfinbr.forms()print:f)=http://www.example.com:81/test.php?pass=550)(readonly)>)>)>=Doit!)(readonly)>>我当前的代码br.open('http://www.bitfarm.co.za/upload.php')br.select_form(nr=4)fil

Python:binascii.a2b_hex 给出 "Odd-length string"

我有一个从文本文件中获取的十六进制值,然后将其传递给a2b_hex以将其转换为正确的二进制表示形式。这是我所拥有的:k=open('./'+basefile+'.key','r')k1=k.read()k.close()my_key=binascii.a2b_hex(k1)当我打印k1时,如预期的那样:81e3d6df这是错误信息:Traceback(mostrecentcalllast):File"xor.py",line26,inmy_key=binascii.a2b_hex(k1)TypeError:Odd-lengthstring有什么建议吗?谢谢!

python - 操作系统错误 : raw write() returned invalid length when using print() in python

我正在使用pythontensorflow训练一个模型来识别python中的图像。但是当我尝试从github执行train.py时出现以下错误Traceback(mostrecentcalllast):File"train.py",line1023,intf.app.run(main=main,argv=[sys.argv[0]]+unparsed)File"C:\Users\sande\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\platform\app.py",line48,inrun_sys.exit

python - AssertionError : incompatible sizes: argument 'height' must be length 2 or scalar (Matplotlib, Python 2.7,绘制图表)

不幸的是,新的一天给Python带来了新的问题:/我有一个由我用Java编写的其他应用程序生成的文件。这个应用程序生成带有一些数据的文件,它是一种随机的东西,因为我无法说出每个文件会有多少行。示例文件如下所示:3SatJan2100:00:0020127SunMar1100:00:0020125FriJan100:00:0020104SatFeb500:00:0020118SunApr1100:00:0020104WedAug2400:00:0020118SatFeb2000:00:0020103ThuOct1300:00:0020119FriDec1700:00:0020104Tue

python - django.db.utils.OperationalError : (1071, 'Specified key was too long; max key length is 767 bytes' )

我的模型:classCourse(models.Model):language=models.ForeignKey(Language)name=models.CharField(max_length=50,unique=True,default='course')title=models.CharField(max_length=1024,default='notitle')foreign_title=models.CharField(max_length=1024,default='notitle',blank=True)header=models.CharField(max_len