How to get a list of a repository branches using Python
问题 I am trying to get a list of all the branches available on my repository using Python with this code : import subprocess branches = ["All"] command = "git branch -r" branch_list = subprocess.check_output(command) for branch in branch_list: print branch branches.append[branch] What I want is to have something like : print branches[0] # is "All" print branches[1] # is "branch1" print branches[2] # is "branch2" etc etc but instead of that I have print branches[0] # is "All" print branches[1] #