Pipe Python输出到文本

Pipe Python输出到文本,pipe,output,Pipe,Output,我想在一个.txt文件中得到这个小脚本的输出,例如 a = input ('what is your first name') b = input ('what is your last name') print ('Hello ' a + b ) 结果是Hello等等,问题是,如何将答案保存到.txt或htm文件。。。非常感谢使用shell重定向。e、 gpython your_script>output.txt我试过了,没用,我只想打印结果,不想打印问题(Hello first last)

我想在一个.txt文件中得到这个小脚本的输出,例如

a = input ('what is your first name')
b = input ('what is your last name')
print ('Hello ' a + b )

结果是Hello等等,问题是,如何将答案保存到.txt或htm文件。。。非常感谢使用shell重定向。e、 g
python your_script>output.txt

我试过了,没用,我只想打印结果,不想打印问题(Hello first last)。有像print('a+b')>>new.txt这样的东西吗?在这种情况下为什么不使用文件处理呢