我有以下功能,我想连接两个字符串,我在这里做什么错?在python中获取名称错误
commands = ["abcd","123"]
def configure_dev(self, steps):
func_name = self.id + ':configure dev'
global conf_cmd
for key in commands:
conf_cmd += key + '\n'
print(conf_cmd)
得到以下错误:
conf_cmd + =键+ '\ n'
它运行后,我得到这个错误: NameError: name 'conf_cmd' is not defined
你在哪里定义了'conf_cmd'? 'global'不会创建新的变量。 –
你将它设置为全局但它是未定义的。 – Fallenreaper
谢谢,这真是愚蠢的我。 – Invictus