无法打开文件:" NameError:name< filename>未定义" [英] Can't open file: "NameError: name <filename> is not defined"

查看:73
本文介绍了无法打开文件:" NameError:name< filename>未定义"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个程序来读取FASTA文件并拆分为某些特定字符,例如'> '等.但是我遇到了问题.

I am creating a program to read a FASTA file and split at some specifc characters such as '>' etc. But I'm facing a problem.

程序部分是:

>>> def read_FASTA_strings(seq_fasta):
...     with open(seq_fasta.txt) as file: 
...             return file.read().split('>') 

错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'seq_fasta' is not defined

如何摆脱这个问题?

推荐答案

您需要将文件名指定为字符串文字:

You need to specify the file name as a string literal:

open('seq_fasta.txt')

这篇关于无法打开文件:&quot; NameError:name&lt; filename&gt;未定义"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆