草庐IT

python - 如何在 Python Git 钩子(Hook)中使用 raw_input()?

我正在为Git编写一个预提交Hook,它运行pyflakes并检查修改后的文件(codeonGithub)中的制表符和尾随空格。我想通过如下要求用户确认来覆盖Hook:answer=raw_input('Commitanyway?[N/y]')ifanswer.strip()[0].lower()=='y':print>>sys.stderr,'Committinganyway.'sys.exit(0)else:print>>sys.stderr,'Commitaborted.'sys.exit(1)此代码产生错误:Commitanyway?[N/y]Traceback(mostrec

python - 如何在 Python Git 钩子(Hook)中使用 raw_input()?

我正在为Git编写一个预提交Hook,它运行pyflakes并检查修改后的文件(codeonGithub)中的制表符和尾随空格。我想通过如下要求用户确认来覆盖Hook:answer=raw_input('Commitanyway?[N/y]')ifanswer.strip()[0].lower()=='y':print>>sys.stderr,'Committinganyway.'sys.exit(0)else:print>>sys.stderr,'Commitaborted.'sys.exit(1)此代码产生错误:Commitanyway?[N/y]Traceback(mostrec