六行各属于哪一类

👁️ 2 人浏览 💬 0 人评论 ❤️ 添加收藏

按"和共同祖先比"给每一行归类:same(两边一样)、ours(只有我改)、theirs(只有对方改)、conflict(都改且不同)。运行下面这段程序:

def classify(b, o, t):
    if o == t:
        return "same"
    if o == b:
        return "theirs"
    if t == b:
        return "ours"
    return "conflict"

def kinds(base, ours, theirs):
    return [classify(b, o, t)
            for b, o, t in zip(base, ours, theirs)]

base = ['HOST = "localhost"', 'PORT = 8000', 'DEBUG = False',
        'TIMEOUT = 30', 'RETRY = 1', 'LOG = "app.log"']
ours = ['HOST = "localhost"', 'PORT = 8080', 'DEBUG = True',
        'TIMEOUT = 60', 'RETRY = 1', 'LOG = "main.log"']
theirs = ['HOST = "0.0.0.0"', 'PORT = 9000', 'DEBUG = True',
          'TIMEOUT = 30', 'RETRY = 3', 'LOG = "sys.log"']
print("/".join(kinds(base, ours, theirs)))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论