返回: Python基础 索引页


假如文件的内容如下:

###
[Action --1]

RDMA support
IPOIB support
RDSOIB support

###<<<

###
[Action --2]

ORA-07445
pevm_icd_call_common
ORA 7445 [pevm_icd_call_common]
oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException:
ContentsXML/oui-patch.xml (Permission denied)

opatch logs

###<<<


想要读入数组后,形成如下结构:

['[Action --1]', 0], ['RDMA support', 'IPOIB support', 'RDSOIB support'],
['[Action --2]', 0], ['ORA-07445', 'pevm_icd_call_common', 'ORA 7445 [pevm_icd_call_common]', 'oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException:', 'ContentsXML/oui-patch.xml (Permission denied)', 'opatch logs']


程序代码如下:

tmpFactor= []
contentsList = []
actionList = []

myfile = open('AI.txt')
line = myfile.readline()
iti = 0
while line:
    current_line = line.strip()
    if ( current_line == "###" ) :  # read the next line when encounter "###"
        line = myfile.readline()
        current_line = line.strip()
        ## <<<<<<<<<< first line , action plan name
        tmpFactor.append( current_line )
        tmpFactor.append( 0 ) # the counter for later summary
        ## <<<<<<<<<<< skip to the line next to [action]
        line = myfile.readline()
    elif ( current_line == "###<<<" )  : # the current group finished
        ##print ( "got to the end" )
        actionList.append(tmpFactor)
        actionList.append(contentsList)
        ##print ( actionList )
        ##make search
        ## go to next item section
        tmpFactor= []
        contentsList = []
        line = myfile.readline()
        ##continue        
        ##break
    else:  #  got the real content to the list
        if ( current_line == '') :
            iti = 0
            ##print ( "null line" )
        else :
            iti = 1
            ##print ( "good line,append" + current_line )
            contentsList.append( current_line ) # append the real content
        line = myfile.readline()
        iti = 2  ## end of else content
    iti = 3 ## end of while content

myfile.close()

print ( actionList )


运行结果如下:

[
['[Action --1]', 0], ['RDMA support', 'IPOIB support', 'RDSOIB support'],
['[Action --2]', 0], ['ORA-07445', 'pevm_icd_call_common', 'ORA 7445 [pevm_icd_call_common]', 'oracle.sysman.oui.patch.PatchException: java.io.FileNotFoundException:', 'ContentsXML/oui-patch.xml (Permission denied)', 'opatch logs']
]


返回: Python基础 索引页

posted @ 2022-04-09 12:50 健哥的数据花园 阅读(421) 评论(0) 推荐(0) 编辑
摘要: 返回: Python基础 索引页 下面的代码,是之前所写的 【Python基础】以条件数组、匹配检查另一个数组的例子的改进版。通过函数实现匹配检查。 def makeSearch(tmpActionList, tmpKeywordList): tmpCnt = 0 tmpVals = tmpActi 阅读全文
posted @ 2022-03-30 10:02 健哥的数据花园 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 返回: Python基础 索引页 此例子,是为了实现:将如下文件的 第一段 "###" 和 "###<<<" 的内容,读入到数组。 ### [Action --1] RDMA support IPOIB support RDSOIB support ###<<< ### [Action --2] O 阅读全文
posted @ 2022-03-29 21:04 健哥的数据花园 阅读(431) 评论(0) 推荐(0) 编辑
摘要: 返回 Oracle 索引页 客户问到,当进行数据导出(expdp) 时速度慢,询问解决的方法。 通过查询,看到在长时间等待的session 中,DataPump 的子进程 DW00,它的 LAST_CALL_ET 很大(7小时以上) set lines 200 pages 2000 col user 阅读全文
posted @ 2022-03-27 15:03 健哥的数据花园 阅读(2269) 评论(0) 推荐(0) 编辑
摘要: 返回: Python基础 索引页 以条件数组、匹配检查另一个数组的例子。对如下的数组:[Actin --3][0] [conditon aa] [conditon kk] [conditon rr] [conditon cc]有另外一个条件数组:"condition aa""condition kk 阅读全文
posted @ 2022-03-20 21:06 健哥的数据花园 阅读(308) 评论(0) 推荐(0) 编辑
摘要: Python基础 索引页 构建三维数组,形如: [Actin --1][0] [conditon aa] [conditon bb] [conditon cc] [Actin --2][0] [conditon dd] [conditon aa] [Actin --3][0] [conditon a 阅读全文
posted @ 2022-03-14 09:14 健哥的数据花园 阅读(750) 评论(0) 推荐(0) 编辑
摘要: 返回: Python基础 索引页如下的例子中,将二维数组按照第二维的降序进行排序 ### Prepare the list complist = [] tmpFactor= [] tmpFactor.append("[Action-1]") tmpFactor.append(3) complist. 阅读全文
posted @ 2022-03-07 14:45 健哥的数据花园 阅读(492) 评论(0) 推荐(0) 编辑
摘要: 返回: Python基础 索引页 希望形成如下的二维数组: [Action --1][3] [Action --2][5] [Action --3][2] [Action --4][1] [Action --5][8] [Action --6][4] 以列表实现,代码如下: simplist = [ 阅读全文
posted @ 2022-03-07 13:37 健哥的数据花园 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 返回: Python基础 索引页 假设有一个如下的列表: mylist = [3, 5, 2, 1, 8, 4] 我希望对其进行排序,达成排序后变成 [1,2,3,4,5,8]。代码例子如下: mylist = [3, 5, 2, 1, 8, 4] tester=0 lcount = len(myl 阅读全文
posted @ 2022-03-07 12:17 健哥的数据花园 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 返回: Python基础 索引页 写一个 For 循环的小例子,代码如下: m = 0; for i in range(5): if i == 3: break; else: m = 1; print(i); print("End"); 运行结果如下: 0 1 2 End 返回: Python基础 阅读全文
posted @ 2022-03-07 11:49 健哥的数据花园 阅读(472) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示