python往文件里写数据,python中二分法查找怎么写

  python往文件里写数据,python中二分法查找怎么写

  我认为可以这样做。(假设输出文件是制表符分隔的。)导入csv

  导入操作系统

  受体=[crystal_1 , modeller_1 , moe_1 ,

   nci5_modeller0000_1 , nci5_modeller0001_1 ,

   nci5_modeller0002_1 , nci5_modeller0003_1 ,

   nci5_modeller0004_1 , nci5_modeller0005_1 ,

   nci5_modeller0006_1 , nci5_modeller0007_1 ,

   nci5_modeller0008_1 , nci5_modeller0009_1 ,

   nci5_modeller0010_1 , nci5_modeller0011_1 ,

   nci5_moe0000_1 , nci5_moe0001_1 , nci5_moe0002_1 ,

   nci5_moe0003_1 , nci5_moe0004_1 , nci5_moe0005_1 ,

   nci5_moe0006_1 , nci5_moe0007_1 , nci5_moe0008_1 ,

   nci5_moe0009_1 , nci5_moe0010_1 , nci5_moe0011_1 ,

  nci5_moe0012_1 , nci5_moe0013_1 , nci5_moe0014_1]

  以open(potentiation.txt )、( rt)为实验,

  打开(输出。CSV)、()wb))作为输出文件:

  () ) ) )

  CSV _ writer.write行([配体]受体)#标题行

  forligandin(线。RStrip))用于实验中的行(: )

  row=[配体]

  对于受体中的蛋白质:

  withopen(蛋白质)。txt , rt )作为文件1:

  found=[Found , Not Found][file1.read()。find()配体)==-1]

  row.append(找到)

  csv_writer.writerow(row)

  打印(输出。CSVfileWritten))

  更新

  我在评论里说过,蛋白质文档看一遍会快很多。因此,为了按照预期的格式打印,需要将每个配体的检查结果存储在数据结构的每个文件中。当每个文件被多次读取和检查时,这个数据结构就会被一步一步地建立起来,所有操作完成后,结果就会被写入一次。这个目的可以通过一个简单的列表来满足,并在下面的实现中使用。在

  而是使用更多的内存,而不是一遍又一遍的读取蛋白质文件。由于磁盘I/o通常是计算机上速度最快的设备之一,所以您可以通过稍微增加代码的复杂性来显著提高性能。在

  下面是表示这个替代版本的代码。

  ^{pr2}$

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: