我想在搜索要更新的WSUS組時比較兩個字符串。然而,即使它們在視覺上看起來是相同的,並且屬於同一類型,我的比較也失敗了。由於這是IronPython,我沒有在Komodo中可用的調試器(任何人都知道一個用於IP?)在IronPython中比較字符串
無論如何,有人可以發現我做錯了什麼嗎?
#----------------------------------------------------------------------
# Search for a matching patch group, and approve them.
#----------------------------------------------------------------------
def WSUSApprove(apprvGrpName):
clr.AddReference('Microsoft.UpdateServices.Administration')
import Microsoft.UpdateServices.Administration
wsus = Microsoft.UpdateServices.Administration.AdminProxy.GetUpdateServer('wsus01',False,8530)
parentGroupCollection = wsus.GetComputerTargetGroups()
for computerTarget in parentGroupCollection:
if computerTarget.Name.ToString() == 'Servers':
parent = computerTarget
childGroupCollection = parent.GetChildTargetGroups()
for computerTarget in childGroupCollection:
print type(computerTarget.Name.ToString())
print type(apprvGrpName)
if apprvGrpName == computerTarget.Name.ToString():
print 'success', computerTarget.Name.ToString()
else:
print 'a', computerTarget.Name.ToString()
print 'b', apprvGrpName
#--output that should be equal--#
<type 'str'>
<type 'str'>
a 3 Tuesday
b 3 Tuesday
它顯示'\ n在其中之一!謝謝你的幫助。咄。 – EdgeCase
我會將其移至答案。請記住接受你的問題的答案(你沒有對你的前兩個)。 – agf