我正在为系统环境变量赋值。基于这个变量的值-true或false,我有了要执行的if和else块。 当该变量的值为false时,它将成功执行else块,但如果该变量的值为true,则它不会执行if块中的语句。你知道吗
代码段是:
propDictionary = globals()
isMtEnabled = propDictionary['convertToMt']
if isMtEnabled == "true" :
if props.getProperty("ClusterName") != None and props.getProperty("ClusterName") != "" :
print "Have a cluster"
clusterNames = clusterName1.split()
print "clusterNames is "
print clusterNames
targetMBeans = []
for clusterName in clusterNames:
storeName='WseeFileStore_'+clusterName
addNamedFileStoreOnServer (storeName,clusterName,distPolicy="Distributed")
else :
counter = 0
c1_arr = []
c2_arr = []
for serverName in serverList:
if serverName.startswith("c1"):
storeName='WseeFileStore_'+serverName
addNamedFileStoreOnServer(storeName,serverName,distPolicy="Distributed")
jmsServer = addJMSServer(serverName,storeName=storeName)
当我打印isMtEnabled变量时,它将打印true或false。 当它的值为true时,它应该执行if块,而不是完全不进入if块。你知道吗
在这种情况下可能有什么问题?你知道吗
你能打印
type(isMtEnabled)
吗?如果结果是布尔值,请将If替换为以下内容:相关问题 更多 >
编程相关推荐