Python中文
首页
教程
问答
标签
搜索
登录
注册
PYTHON索引器错误:元组索引超出范围
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>非常感谢您对这个问题的反馈</p> <pre><code>import subprocess def main(): ''' Here's where the whole thing starts. ''' #Edit this constant to change the file name in the git log command. FILE_NAME = 'file1.xml' #Do the git describe command to get the tag names. gitDescribe = 'git describe --tags `git rev-list --tags --max-count=2`' print ('Invoking: {0}'.format(gitDescribe)) p1 = subprocess.Popen(gitDescribe, shell=True, stdout=subprocess.PIPE) output = p1.stdout.read() #Get the first 2 tags from the output. parsedOutput = output.split('\n') tag1 = parsedOutput[0] tag2 = parsedOutput[1] print('First revision: {0}'.format(tag1)) print('Second revision: {1}'.format(tag2)) #Do the git log command for the revision comparison. gitLog = 'git log {0}..{1} --pretty=format:"%an %h %ad %d %s" --date=short --topo-order --no-merges {2}'.format(tag1, tag2, FILE_NAME) print('Invoking: {0}'.format(gitLog)) p2 = subprocess.Popen(gitLog, shell=True, stdout=subprocess.PIPE) output = p2.stdout.read() print(output) if __name__ == "__main__": main() </code></pre> <p>。。。</p> <pre><code>bash-3.2$ python pygit5.py Invoking: git describe --tags `git rev-list --tags --max-count=2` First revision: 14.5.5.1 Traceback (most recent call last): File "pygit5.py", line 31, in <module> main() File "pygit5.py", line 22, in main print('Second revision: {1}'.format(tag2)) IndexError: tuple index out of range </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p><code>tag2</code>只是一个值,比如<code>tag1</code>,所以不能引用项[1]。毫无疑问你是说</p> <pre><code>print('Second revision: {0}'.format(tag2)) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何合并多个PDF文件?
1 回答
如何合并多个xarray数据变量及其坐标?
5 回答
如何合并多个列中具有重复值的行
3 回答
如何合并多个唯一id
9 回答
如何合并多个图纸并使用图纸名称的名称重命名列名?
4 回答
如何合并多个字典并添加同一个键的值?(Python)
7 回答
如何合并多个搜索结果文件(pkl)以将它们全部打印在一起?
1 回答
如何合并多个数据帧
9 回答
如何合并多个数据帧并使用Pandas为假人添加列?
10 回答
如何合并多个数据帧并按时间戳排序
2 回答
如何合并多个数据帧的列表并用另一个lis标记每列
7 回答
如何合并多个数据框中的列
4 回答
如何合并多个文件?
2 回答
如何合并多个查询集?
8 回答
如何合并多个绘图?
2 回答
如何合并多个词典
7 回答
如何合并多个输入数据集(数据帧)?
4 回答
如何合并多条记录中拆分的文本行
9 回答
如何合并多索引列datafram
7 回答
如何合并多级(即多索引)数据帧?
2 回答