print 方法默认调用 sys.stdout.write 方法,即往控制台打印字符串。
当然二者也有区别:1.sys.stdout.write()结尾没有换行,而print()是自动换行的。2.write()只接收字符串格式的参数3.print()能接收多个参数输出,write()只能接收一个参数。以下是区别代码:
def Inface_Test():
print("这是print")
sys.stdout.write("这是")
sys.stdout.write("write")