pythonITeye - AG环亚娱乐集团

pythonITeye

2019-01-10 18:07:31 | 作者: 博耘 | 标签: 用法,不同,版别 | 浏览: 2466



版别不同语法不同

1. print (‘’) print  ‘’

2.input 与 raw_input 

3代码(if和else用法):

number = 23guess = int(input (Enter an integer:))

if guess == number: print (Congratulations, you guessed it.) print ( quot;(but you do not win any prizes!) quot;)elif guess number: print (No ,it is a little higher than that)else : print (No, it is a little lower than that)print (Done)

4.while用法,可带一个else

number = 23running = True 

while running: guess = int (input (Enter an integer:)) if guess == number: print (Congratulations , you guessed it.) running = False  elif guess number: print (No, it is a little higher than that) else : print (No, it is a little lower than that)else : print ( The while loop is over.)print (Done)

5.for用法

for i in range (1, 5): print (i)else : print (The for loop is over )

6. break 用法

while True: s = input (Enter something:) if s == quit: break print (Length of the string is, len(s))print (Done)

7.continue 用法

while True: s = input (Enter something:) if s == quit: break if len(s) 3: continue print ( input is of sufficient length)

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表AG环亚娱乐集团立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章

阅读排行

  • 1

    简历打分排序ITeye

    排序,简历,体系
  • 2

    如何用Redlock完成分布式锁ITeye

    分布式,完成,获取
  • 3
  • 4

    java 批量推送 iosITeye

    推送,测验,内容
  • 5
  • 6
  • 7
  • 8

    递归算法和文件行列算法ITeye

    文件,行列,文件夹
  • 9

    链表结构ITeye

    结点,保存,删去
  • 10