首页 > 代码库 > python sys.sdout.write 和print 区别

python sys.sdout.write 和print 区别

sys.sdout.write 标准输入相当于“%value%”,输出内容没有空格,而print输出带有空格,举个例子

 

用sys.sdout.write;

import sysfor i in range(1,11):    for j in range(1,i+1):        #print"##",       sys.stdout.write("$$")    print ""

输出

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
import sysfor i in range(1,11):    for j in range(1,i+1):        print"##",       #sys.stdout.write("$$")    print ""#输出## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## 

 

python sys.sdout.write 和print 区别