python批量读取文件赋值给一个参数

我想创建一个可以打开文本文件c_name.txt的脚本,其中文本文件的内容将是单元名称列表。 打开后,我需要将所有单元名称指定为变量。 这是因为我需要单元名称来打开下一个需要单元名称的目录。 我现在做的是打开文本文件并打印单元格名称。 我不知道如何读取单元格名称并分配给变量。 我需要将所有单元名称分配到一个数组中吗?

This is my script:#!/usr/bin/python

import os

import os.path

myPWD = os.getcwd()

workspace = "%s/.." %(myPWD)

floc = '/'.join([workspace, "test", "c_name.txt"])

with open(floc,"r+") as f1:

for line in f1:

print line

#I need to get each of the cell name to open cell_name.rpt for the next step

floc2 = '/'.join([workspace, "library", "$ce_ or $cell", "$cell_name.rpt"])

我还需要分类,如果单元名称以ce_开头,则报告文件将位于ce_目录中,而如果单元名称以cell开头,则报告文件将位于单元目录中。

这是我的c_name.txt:ce_clk

celladd

ce_sum

cellsub

After i get to open each cell_name.rpt, I need to grab input from the report file for the next step.

猜你喜欢

转载自blog.csdn.net/SAPmatinal/article/details/131741553