python - TypeError: list indices must be integers, not dict -


My JSON file has been liked and I want to sign in to syslog I'm trying to loop "." "" "" "/ Home / FBML7HR / log", "logfilename": ""}, "preparation": {"configuration": {"Src_configfile": "src.cfg", "dest_configfile": "/ var / home / FBML7HR / etc / vxn.cfg "}," executable_enary1 ": [{" login_info ": {" hostname ":" 10.4.0.xxx "," user name ":" *** "," Password ":" *** "}}, {" command ": {" folder path ":" / var / home / FBML7HR / SrcCode / vxnservers / fdchost / answer / "{@}" "" "" "" "" "" "" "" "User name": "***", "password": "***"}}, {"command": {"folderpath": "/ var / home / FBML7HR / SrcCode / Vxnservers / fdchost / reply / build / linux-2.6.18-194.8.1.el5 / bin "," processname ":" answerhost "," parameter ":" -sbr Jail-D "}}]," Executive_Info3 ": [{" login_info ": {" hostname ":" 10.4.0.xxx "," username ":" *** "," password ":" ** * "}", {"Command": "320/205 14897 16880 60000 60000 2 2" {0} ":" cd / var / home / xxx / srccode / vxnservers / fdchost / north / test / vxnclient_mt "," Process name ":" Vxnclient_north_mt "," parameter ":" 0 320 205 14897 16880 60000 60000 2 2 "}}]}," execution ": [{" test_case ": {" scriptname ":" / var / home / FBML7HR / test " / Testcase1.sh "," testreport ": {" syslog ":" / var / log / "" Backuplogs1.txt "," clientimlog ":" / var / home / FBML7HR / test / out.log "," backupclientsimlog " : "" {"Test_case": "" / "/ var / home / FBML7HR / test / testcase2.sh", "testreport": {"syslog": "/ var / log / message" , "Backup" logs: "backuplogs2.txt", "{" Testreport ": {" syslog ":" / var / home / FBML7HR / test / out.log "," backupclientsimlog ":" Clientlogs2.txt "}}}}," verification "," / log / message "," backuplogs " txt "," reportfilename ":" / var / home / FBML7HR / test / out.log "," backuplogfile ":" Clientlogs.txt "}}}

I ['execution'] in the data: CMD = data ['execution'] [i] ['test_case'] ['sCRIPTNAME script']

but type "error in error: get error list: list index should be integer, not dict" I'm new to python (and Jason also) what to give a suggestion Awareness Why am I wrong?

You values ​​ data ['execution'] , not list referenced by index

just use those values ​​(dictionary) right ' data 'I [' execution ' ] for

 : cmd = i [ 'test_case'] [ 'script name']   

perhaps a more meaningful loop that you want to name:

  entry in the data [ 'execution']: cmd = entry [ 'test_case'] [ 'scriptname']    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -