print的区别
在py2中print是一个语法结构,而在py3中print是一个函数,
print(value, ..., sep=' ', end='\n',file=sys.stdout, flush=False)
file可以是文件,也就是可以把打印的东西直接输出到文件,这个就很方便,我经常用。比如:
a = range(10) out_file = open(“print_test_file.txt”, ‘w’) for x in a: print(x,sep=’ ‘, end = “\n”, file=out_file)
另外:


浙公网安备 33010602011771号