【问题标题】:Python - AttributeError: indexPython - 属性错误:索引
【发布时间】:2011-05-11 10:41:50
【问题描述】:

我被困在这里...

使用用户 ID weblogic 连接到 t3://localhost:7001 ... 已成功连接到属于域“wl_server”的管理服务器“examplesServer”。

警告:使用了不安全的协议连接到 服务器。为确保在线安全,SSL 端口或 应该使用管理端口。

[MBeanServerInvocationHandler]com.bea:Name=mainWebApp,Type=AppDeployment ParcelLienData.war ParcelLienData 磷 调用 WLST 时出现问题 - Traceback(最里面的最后一个): 文件“D:\RM-Share\RM-Scripts\wl_deploy_localhost-WC.py”,第 30 行,在? 属性错误:索引

我的代码如下:

import sys 
import getopt
import os

loadProperties(sys.argv[1] +".props")
connect(username,password,adminUrl)

cmd = "awk -F'Name=' '{print $2}' | awk -F',' '{print $1}'"

f = open(r'./applicationsList.txt','r')
#In Above line you can specify the Complete Path of the "applications.txt" as well

print f
for i in range(5):
       line=f.readline()
       line1=line[:-4]
       line2=line1[:1]
       #check if the service or application is already present on the server...
       cd('AppDeployments')
       myapps=cmo.getAppDeployments()
       for dep_file in myapps:
          print depfile
          print line
          print line1
          print line2
          num1=depfile.index(line2)
          print num1
          num2=depfile.index(",", num1)
          print num2
          appName=depfile[num1:num2]
          print appName

          if appName == "line1":
             print Redeploy
          elif appName != "line1":
             print "Not deploying"
             continue
          else:
             print Deploying

请指教,我哪里错了......

谢谢....

【问题讨论】:

    标签: python indexing attributeerror


    【解决方案1】:

    错误告诉你这一行:

    appName=dep_file[num1:num2]
    

    错了。你确定dep_file 对象可以用切片索引吗?

    也许您应该先在dep_name 上致电getName()

    【讨论】:

    • 嘿,我对python很陌生,不知道你指的是什么,我在博客上找到了一段代码如下......我想根据我的使用和更新要求...请帮助 >>> line = '(仅限单词): 婴儿里程碑

      ' >> > line.index("B") 44 >>> line.index(">> line[44:59] 'BABY MILESTONES'
    • 但它工作正常,当我在命令行上传递相同的命令集时
    • 您好 Eli,感谢您的建议,您是对的,我按照下面提到的方式使用并得到了它的工作......谢谢。 appName=appLine.getName()
    猜你喜欢
    • 2010-10-01
    • 2014-03-21
    • 2013-07-01
    • 2011-10-12
    • 1970-01-01
    • 2017-02-23
    • 2016-05-14
    • 2018-02-22
    • 1970-01-01
    相关资源
    最近更新 更多