-4

私はこのコードをデバッグしてきましたが、==一致する 2 つの文字列に対して演算子を機能させることができませんでした。

コード:

str1 = "string1"
str2 = "string2"

print str1
print str2

for row in results:
  print row[0]
  print row[1]   #as requested
  if((row[0] == str1) and (row[1] == str2)):
     print "We found the match....."
     #rest of the code
4

1 に答える 1

2

必ず。で空白を削除して.strip()ください。

>>> str1 = "string1"
>>> str2 = "string2"
>>>
>>> results = [["string1 ", " string2"]]
>>> for row in results:
...   if((row[0].strip() == str1) and (row[1].strip() == str2)):
...      print "We found the match....."
...
We found the match.....
>>>
于 2012-10-03T01:57:58.963 に答える