pyhton随笔02

一、如何实现输入密码时不可见?

import getpass

pwd= getpass.getpass(“请输入密码:")

(pycharm内可能不可用)

二、if.....else

age=25

guess_age = int(input(‘你猜我多少岁?‘)) #python3.X 中input的是一个str,需要int()

if guess_age == age:

  print(‘Yes,you got it!‘)

elif guess_age > age:

  print(‘think smaller‘)

else :

  print(‘think bigger‘)

三、while

count = 0

while True:

  print(‘count:’,count)

  count = count +1

#guess age

age=25

count = 0

while count < 3:

  guess_age = int(input(‘你猜我多少岁?‘))

  if guess_age == age:

    print(‘Yes,you got it!‘)

  elif guess_age > age:

    print(‘think smaller‘)

  else :

    print(‘think bigger‘)

  count +=1

  if count ==3:

    continue_confirm = input(‘Do you want to continue?‘:)

      if continue_confirm != "n":

        count = 0

#else:

#  print(‘you have try too many times‘)

三、for循环

for i range(10):

  print(”loop:“,i)

for i range(0,10,3):#从0开始,到10结束,步长为3

  print(”loop:“,i)

#guess age

age=25

count = 0

for i in range(3):

  guess_age = int(input(‘你猜我多少岁?‘))

  if guess_age == age:

    print(‘Yes,you got it!‘)

  elif guess_age > age:

    print(‘think smaller‘)

  else :

    print(‘think bigger‘)

  count +=1

else:

  print(‘you have try too many times‘)

#! usr/bin/env python# encoding:utf-8# __author__="Macal"‘‘‘for i in range(0,10):    if i < 5:        print("loop",i)    else:        continue    print(‘hehe‘)‘‘‘for i in range(10):    print(‘----------‘, i)    for j in range(10):        print(j)        if j > 5:            break #结束当前循环

 

时间: 2024-10-13 18:17:25

pyhton随笔02的相关文章

python随笔02

1.改变字符串的首字母为大写 s = 'welcome to bokeyuan' s1 = s.capitalize() print () 2.将字符串全部变为大小写 s = 'Welcome To Bokeyuan' s1 = s.capitalize() s2 = s.upper() s3 = s.lower() print(s2) print(s3) 3.将字符居中,可以添加填充来代替 s = 'menu' s4 = s.center(20) s5 = s.center(20,'-') p

JDK8的随笔(04)_Lambda表达式扩展之Method References

Method References 方法参照 对于Method Reference了解之前先了解Lambda表达式. 参看: JDK8的随笔(01)_Lambda表达式是个神马东东,初尝禁果 JDK8的随笔(02)_Lambda表达式进一步探讨 JDK8的随笔(03)_Lambda表达式的变量使用范围讨论 Method References 的出现场景 Lambda表达式本身是一个延迟加载采用实现函数式接口的方式来简短代码提高可读性(刚开始可能会降低可读性,熟了就觉得效率很高),减少各种缩进括号

百度刚放假啊数据库风口浪尖萨拉疯了

http://www.ebay.com/cln/l_x5585/2015.02.11/176746639012 http://www.ebay.com/cln/jiacha_boryk/2015.02.11/176837188016 http://www.ebay.com/cln/gbnlin0/2015.02.11/176837189016 http://www.ebay.com/cln/j_j2841/2015.02.11/177066749015 http://www.ebay.com/c

百度房间爱师傅卡卡是快乐疯了;爱死

http://www.ebay.com/cln/shx9479/-/177007606013/2015.02.11 http://www.ebay.com/cln/genqi12/-/176846034010/2015.02.11 http://www.ebay.com/cln/seyyon2/-/176906811016/2015.02.11 http://www.ebay.com/cln/wcn5971/-/176846032010/2015.02.11 http://www.ebay.co

百度和房价是否健康教案上开发

http://www.ebay.com/cln/l.kuan2/-/167247714018/2015.02.10 http://www.ebay.com/cln/setlia-3616/-/167086016019/2015.02.10 http://www.ebay.com/cln/pen-y77/-/167086017019/2015.02.10 http://www.ebay.com/cln/yua-me2/-/167399441016/2015.02.10 http://www.eba

百度电话费健身房拉伸件礼服加拉斯减肥

http://www.ebay.com/cln/cnli_c90nphs5e/-/167379958016/2015.02.07 http://www.ebay.com/cln/gaw4612/-/167226239018/2015.02.07 http://www.ebay.com/cln/re_len4/-/167263594010/2015.02.07 http://www.ebay.com/cln/ta.ku83/-/167162702017/2015.02.07 http://www.

百度回复金卡是减肥拉进来收付款

http://www.ebay.com/cln/cnli_c90nphs5e/-/167379958016/2015.02.08 http://www.ebay.com/cln/gaw4612/-/167226239018/2015.02.08 http://www.ebay.com/cln/re_len4/-/167263594010/2015.02.08 http://www.ebay.com/cln/ta.ku83/-/167162702017/2015.02.08 http://www.

百度放假哈萨克就发了设计费拉萨

http://www.ebay.com/cln/ldicn.mz6dm/2015.02.11/177030163015 http://www.ebay.com/cln/tan_qi5/2015.02.11/176903144013 http://www.ebay.com/cln/l.lu104/2015.02.11/177030175015 http://www.ebay.com/cln/ya01191/2015.02.11/176722580014 http://www.ebay.com/cl

百度房间撒谎发卡上就发了空间啊

http://www.ebay.com/cln/h-h4129/2015.02.11/176819191016 http://www.ebay.com/cln/fendo88/2015.02.11/176613943017 http://www.ebay.com/cln/ygon288/2015.02.11/176727517018 http://www.ebay.com/cln/ta.ch17/2015.02.11/176613950017 http://www.ebay.com/cln/g-