这是一段代码:
local_ref, local_sha1, remote_ref, remote_sha1 = [line for line in sys.stdin][0].split(' ')
for i, commit in enumerate(repo.iter_commits('docs-and-config')):
print("remote_sha1 is {}\n".format(remote_sha1), "commit.hexsha is {}\n".format(commit.hexsha))
print(type(remote_sha1), type(commit.hexsha))
print(commit.hexsha == remote_sha1)
if commit.hexsha == remote_sha1:
remote_commit = commit
if i > 10:
break
这里是前三个迭代的结果:
remote_sha1 is 9c5e0c813f8ac8bf95997911c7845aec935f1d43 commit.hexsha is ad0632a1e17c03d65124154a7f1f8d7c23966fbf <class 'str'> <class 'str'> False remote_sha1 is 9c5e0c813f8ac8bf95997911c7845aec935f1d43 commit.hexsha is e63f31ba923dca63917c1ed3a9d332f9c42baf83 <class 'str'> <class 'str'> False remote_sha1 is 9c5e0c813f8ac8bf95997911c7845aec935f1d43 commit.hexsha is 9c5e0c813f8ac8bf95997911c7845aec935f1d43 <class 'str'> <class 'str'> False
为什么第三实例不相等?我试图从两个字符串中删除空格;没什么区别。