python5

print应用

// 输出两行

print "hahaha"

print "hehehe"

// 输出在同一行里

print "hahaha",

print "hehehe"

// 输出到文件

f = open("xxx.txt", "w")

print >> f,"hahaha"

f.close()

控制流语句

// if

if True:

  print("True")

elif not True:

  print("not True")

else:

  pass// pass代表什么都不执行

三元表达式:6 if 10<9 else 4

// while

while True:

  print("True")

else:// while结束后再执行这

  print("end")

// for

for item in range(2):

  print (item)

else:

  print(item)

// break和continue的运用

布尔值

and、or、is、==、not

原文地址:https://www.cnblogs.com/dulianyong/p/10070867.html