美文网首页
基础篇16-python语句1.1

基础篇16-python语句1.1

作者: 梦归游子意 | 来源:发表于2017-01-17 16:32 被阅读0次
Paste_Image.png
  1. print逗号
print a,
print b,
print c   #不会换行
  1. 重定向
with open('print.txt', 'w') as f:
    print >> f, 'hahahahha', 
    print >> f, 'xixixixixiix'
  1. 布尔值
if True:
  print 1

x = 3
if x:
  print '4'  # print 3和print '3'为什么在终端输出效果一样?print(3)和print('3')为什么也一样?

if x is True:#这里是有错误的,因为这里其实有个转义,是if bool(x):
  print 3

3 is True  #返回False
bool(3) is True  #返回True
1 is True #返回True

相关文章

网友评论

      本文标题:基础篇16-python语句1.1

      本文链接:https://www.haomeiwen.com/subject/bybmbttx.html