0
我正在使用gitpython來做一些文件處理。一切工作正常,除了d.new_file條件,我遇到這種類型的錯誤,我不能連接NoneType和str在一起。TypeError:不支持的操作數類型爲+:'NoneType'和'str'使用GITPYTHON
我認爲d.a_path是無,但我不明白爲什麼它不工作,但它在其他條件下工作。
for d in repo.head.commit.diff(None,create_patch=True):
if d.deleted_file:
print("deleted file")
elif d.new_file:
print(" new_file")
with open(main_dir,'a+') as main_file:
main_file.write(d.a_path +'\n')
elif d.renamed_file:
print("renamed file")
else:
print(" modified file")
with open(main_dir,'a') as main_file:
main_file.write(d.a_path+"\n")
handle_diff(d.diff)
有人知道爲什麼d.a_path爲None爲d.new_file條件?