gpt4 book ai didi

python - scons/SConscript 文件的缩进错误

转载 作者:数据小太阳 更新时间:2023-10-29 03:19:37 28 4
gpt4 key购买 nike

我正在尝试编写一个 SConscript 文件,以便我可以使用 scons 构建 Go 代码。 SConscript 文件非常简单;它只是一个入门文件:

def gc(source, target, env, for_signature):
targets = target[0]
sources = " ".join(str(s) for s in source)
print(sources)
return 'go build {}'.format(sources)


go_compiler = Builder(
generator=gc,
src_suffix='.go',
)

# Create environment
env = Environment(
BUILDERS={'Go': go_compiler, }
)

# Build programs
main_package = env.Go(target='helloworld', source='helloworld.go')

但我一直收到这个错误:

# scons
scons: Reading SConscript files ...
File "/root/repo/SConstruct", line 5

print(sources)

^

IndentationError: unexpected indent

我尝试在 python v2.7 和 3.7 之间切换,以各种不同的方式重写代码,但我一直遇到同样的问题。我什至尝试在 python 解释器中编写上述代码的几个片段,语法和缩进都很好。

最佳答案

我从网上复制/粘贴了一些代码。原来有一些嵌入式标签,但我的编辑器使用了空格。所以有几行缩进不一致。我花了几个小时看这个,所以我想我会分享我的错误。

关于python - scons/SConscript 文件的缩进错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56014056/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com