注意点2-print输出

print 默认输出是换行的,==如果要实现不换行需要在变量末尾加上 end=””==;

1
2
3
4
5
6
7
8
9
10
11
x="a"
y="b"
# 换行输出
print( x )
print( y )

print('---------')
# 不换行输出
print( x, end=" " )
print( y, end=" " )
print()

格式化字符串输出

1
2
print("the price  is  %.2f" %num)
print ("我叫 %s 今年 %d 岁!" % ('小明', 10))