[英]Syntax error when importing CSV file (Python)
我对 Python 相当陌生,正在使用它来解析一些数据。 出于某种原因,当我运行时:
将 numpy 导入为 np
def main():
try:
sequencename, modelaccession, modelname, bitscore, e-value, -, hmmstart, hmmend, hmmlength, strandofhit, alignmentstart, alignmentend, envelopestart, envelopeend, sequencelength, descriptionoftargetsequence = np.loadtxt(('7202HEVRK3.csv')
,delimiter= ','
,unpack = True
,dtype='string')
print sequencename
except Exception, e:
print str(e)
我收到语法错误。 如果有人能帮助我,我将永远感激不尽。 这是文件名:7202HEVRK3(它是一种 CSV 格式)。
编辑:语法错误是“无效语法”
发生语法错误是因为您试图为-
(减号运算符)赋值。 通过将-
更改为_
语法错误将被删除,因为 python 将_
作为占位符读取。 您很可能打算这样做,但忘记按下换档按钮。 还要从e-value
删除-
并将其替换为_
。
请尝试以下操作:
try:
sequencename, modelaccession, modelname, bitscore, e_value, _, hmmstart, hmmend, hmmlength, strandofhit, alignmentstart, alignmentend, envelopestart, envelopeend, sequencelength, descriptionoftargetsequence = np.loadtxt('7202HEVRK3.csv',
delimiter= ',',
unpack = True,
dtype='string')
print sequencename
except Exception, e:
print str(e)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.