小编Cha*_*d D的帖子

参数中的3个点是什么?/什么是变量arity(...)参数?

我想知道...Java中的参数是如何工作的.例如:

public void method1(boolean... arguments)
{
  //...     
}
Run Code Online (Sandbox Code Playgroud)

这是一个array吗?我应该如何访问参数?

java arrays parameters methods arguments

8
推荐指数
1
解决办法
4173
查看次数

在两个不同的文件中显示重复的行

我有两个文件,我想显示重复的行.我试过这个,但它不起作用:

cat id1.txt | while read id; do grep "$id" id2.txt; done

我想知道是否有任何其他方式来显示文件中的重复行.我的两个文件都包含id列表.谢谢.

linux bash

5
推荐指数
2
解决办法
1万
查看次数

如何使函数返回每个可能的值

所以我正在使用这种方法,它在查找数字方面工作正常,但它只返回最后一个值.是否有一种方法可以使它在每次运行后返回所有值.这是我的代码:

def searchPFAM():

    fileAddress = '/Volumes/interpro/data/Q14591.txt'
    start = None
    end = None
    with open(fileAddress,'rb') as f:
        root = etree.parse(f)
        for lcn in root.xpath("/protein/match[@dbname='PFAM']/lcn"):#find dbname =PFAM
            start = int(lcn.get("start"))#if it is PFAM then look for start value
            end = int(lcn.get("end"))#if it is PFAM then also look for end value
            print start, end
        return start, end
Run Code Online (Sandbox Code Playgroud)

python lxml return

3
推荐指数
1
解决办法
120
查看次数

类型错误需要字符串或缓冲区,在python中找到的文件

因此,当我单独编写这一块代码时,它工作正常但是当我将它们组合在一起时它会给我typeError.为什么会这样?当我单独写它时它我没有得到它它工作正常.提前致谢 :)

def printOutput(start, end, makeList):

  if start == end == None:

      return

  else:

      print start, end

      with open('OUT'+ID+'.txt','w') as outputFile:#file for result output
          for inRange in makeList[(start-1):(end-1)]:
              outputFile.write(inRange)
          with open(outputFile) as file:
              text = outputFile.read()
      with open('F'+ID+'.txt', 'w') as file:
        file.write(textwrap.fill(text, width=6))
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
2907
查看次数

中断语法错误:语法错误

我休息有什么问题?当我编译代码时,我不明白为什么它说我的休息时语法无效

for index, (start, end) in enumerate(searchPFAM(fname)):            
    with open('output_'+uniprotID+'-%s.txt' % index,'w') as fileinput:
        print start, end
        for item in lookup[uniprotID]:
            item, start, end = map(int, (item, start, end)) #make sure that all value is int
            if start <= item <= end:
                print item
                result = str(item - start)
                fileinput.write(">{0} | at position {1} \n".format(uniprotID, result))
                #text = fileinput.write(''.join(makeList[start-1:end]))
                textwrap.fill(''.join(makeList[start-1:end],width = 60)
                break
            else:
                fileinput.write(">{0} | N/A\n".format(uniprotID))
                #text = fileinput.write(''.join(makeList[start-1:end]))
                textwrap.fill(''.join(makeList[start-1:end],width = 60)
Run Code Online (Sandbox Code Playgroud)

python syntax break

0
推荐指数
1
解决办法
4549
查看次数

在服务器上找不到文件时停止代码崩溃的方法?

所以我的问题是,当其中一个代码无法在服务器中找到该文件时,我的代码会崩溃.有没有办法在找不到文件时跳过查找过程并继续循环.这是我的代码如下:

fname = '/Volumes/database/interpro/data/'+uniprotID+'.txt'

for index, (start, end) in enumerate(searchPFAM(fname)):
        with open('output_'+uniprotID+'-%s.txt' % index,'w') as fileinput:
            print start, end
            for item in lookup[uniprotID]:
                item, start, end = map(int, (item, start, end)) #make sure that all value is int
                if start <= item <= end:
                    print item
                    result = str(item - start)
                    fileinput.write(">{0} | at position {1} \n".format(uniprotID, result))
                    fileinput.write(''.join(makeList[start-1:end]))
                    break
            else:
                    fileinput.write(">{0} | N/A\n".format(uniprotID))
                    fileinput.write(''.join(makeList[start-1:end]))
Run Code Online (Sandbox Code Playgroud)

fname = '/Volumes/database/interpro/data/'+uniprotID+'.txt'

for index, (start, end) in enumerate(searchPFAM(fname)):
        with open('output_'+uniprotID+'-%s.txt' % index,'w') as fileinput: …
Run Code Online (Sandbox Code Playgroud)

python crash loops file

-2
推荐指数
1
解决办法
1665
查看次数

标签 统计

python ×4

arguments ×1

arrays ×1

bash ×1

break ×1

crash ×1

file ×1

java ×1

linux ×1

loops ×1

lxml ×1

methods ×1

parameters ×1

return ×1

syntax ×1