- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将非常感谢您的帮助。我从我的代码的这一部分中收到一条错误消息,如下所述,我想用它来通过 affymetrix 微阵列分析(原始数据链接是 https://www.ncbi.nlm.nih.gov/sites/GDSbrowser?acc=GDS1615 )阐明克罗恩病和溃疡性结肠炎条件下的差异表达基因。但是当我运行这段代码时:
import gzip
import numpy as np
"""
Read in a SOFT format data file. The following values can be exported:
GID : A list of gene identifiers of length d
SID : A list of sample identifiers of length n
STP : A list of sample descriptions of length d
X : A dxn array of gene expression values
"""
fname = "../Anchang Charles/GDS1615_full.soft.gz"
with gzip.open(fname) as fid:
SIF = {}
for line in fid:
if line.startswith(line, len("!dataset_table_begin")):
break
elif line.startswith(line, len("!subject_description")):
subset_description = line.split("=")[1].strip()
elif line.startswith(line, len("!subset_sample_id")):
subset_ids = [x.strip() for x in subset_ids]
for k in subset_ids:
SIF[k] = subset_description
#.next().split("\t")
SID = fid.next().split("\t")
I = [i for i,x in enumerate(SID) if x.startswith("GSM")]
SID = [SID[i] for i in I]
STP = [SIF[k] for k in SID]
我收到一条错误消息,内容为
回溯(最近一次调用最后一次):
文件“”,第 1 行,位于 runfile('C:/Users/Anchang Charles/new affymetrix.py', wdir='C:/Users/Anchang Charles')
文件“C:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py”,第 866 行,在运行文件中 execfile(文件名,命名空间)
文件“C:\Anaconda\lib\site-packages\spyder\utils\site\sitecustomize.py”,第 102 行,在 execfile 中 exec(编译(f.read(),文件名,'exec'),命名空间)
文件“C:/Users/Anchang Charles/new affymetrix.py”,第 1 行,位于 从 affymetrix 导入 X,GID,STP,SID,UC,CD
文件“C:\Users\Anchang Charles\affymetrix.py”,第 26 行,位于 SID = fid.next().split("\t")
属性错误:“GzipFile”对象没有属性“next”
最佳答案
在 Python 3 中,iterator.next()
已替换为 iterator.__next__()
,但您应该使用内置 来调用它next
函数如下:
next(iterator)
所以尝试一下:
next(fid).split("\t")
在 PEP 3114 中了解更多相关信息
改变背后原因的关键:
The use of double underscores creates a separate namespace for names that are part of the Python language definition, so that programmers are free to create variables, attributes, and methods that start with letters, without fear of silently colliding with names that have a language-defined purpose. (Colliding with reserved keywords is still a concern, but at least this will immediately yield a syntax error.)
The naming of the next method on iterators is an exception to this convention. Code that nowhere contains an explicit call to a next method can nonetheless be silently affected by the presence of such a method. Therefore, this PEP proposes that iterators should have a
__next__
method instead of anext
method (with no change in semantics).
关于python - 属性错误: 'GzipFile' object has no attribute 'next' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43356922/
我基本上想完全按照 gzip.GzipFile 的文档中的内容进行操作: Calling a GzipFile object’s close() method does not close fileo
想象一下下面的简单脚本: def reader(): for line in open('logfile.log'): # do some stuff here like sp
我将非常感谢您的帮助。我从我的代码的这一部分中收到一条错误消息,如下所述,我想用它来通过 affymetrix 微阵列分析(原始数据链接是 https://www.ncbi.nlm.nih.gov/s
我需要用 Python 处理一个 .gz 文件。 我将文件名传递到我的 Python 脚本中: infile = sys.argv[1] with gzip.open(infile, 'rb') as
我想阅读gzip并更新内容。 但是,我收到错误 'AttributeError: 'GzipFile' object has no attribute 'extrastart''. import gz
在 Python 2.7 (Pandas 0.22.0) 中,将 Pandas 数据帧保存到内存中的压缩 csv 工作方式如下: from io import BytesIO import gzip
这就是我正在做的 sudo gem install rails ERROR: While executing gem ... (Zlib::GzipFile::Error) unexpect
我正在将内容写入内存中的二进制流,以便将内容上传到 S3,而不将其存储在本地文件中(我的内存比磁盘空间多)。以下代码有效,但 mypy mvce.py失败 mvce.py:6: error: Argu
我使用 Bottle 来接收压缩后的请求正文。当请求的大小很小时,一切都很好。但是,如果请求正文的大小稍大(例如,>= 20kb),则会抛出 IOError。 以下是读取并解压请求体的代码: @pos
我正在使用 Python 研究 Stack Overflow API。我正在尝试解码 API 提供的压缩响应。 import urllib, gzip url = urllib.urlopen('ht
我正在开发 Sencha touch 2 应用程序。我一直在关注“Styling the user interface of a Sencha Touch application”关于 secha t
我正在尝试使用以下 Ruby 代码解压缩文件。 File.open("file_compressed.gz") do |compressed| File.open("file_decomp","w
我在运行时收到奇怪的 bundle 程序错误 bundle pack 使用 bundle 器0.9.12 有任何想法吗? (有关更好的格式化代码,请参见pastie:http://pastie.org
我是一名优秀的程序员,十分优秀!