码迷,mamicode.com
首页 > 其他好文 > 详细

day01学习总结(20170213)

时间:2017-02-15 18:36:51      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:pop   popen   password   输入   long   get   pre   end   username   

#1测试判断用户与密码是否正确:
import getpass
username = "llz"
password = "123455"
_username = input("请输入用户名:")
#assword = getpass.getpass("请输入密码:")
_password = input("请输入密码:")
if _username == username and _password == password:
print("wlelcome user {name} longin ...".format(name = username))
else:
print("Invalid user or name!")

#2猜年龄的游戏1:
age_of_oldboy = 70
guess_age = int(input("guess oldboy_age:"))
if guess_age == age_of_oldboy :
print("yes,you got it!")
elif guess_age > age_of_oldboy:
print ("guess smaller...")
else:
print("guess it bigger...")

#3猜年龄的游戏.循环方法01:
age_of_oldboy = 56
count = 0
while count < 3:
guess_age = int(input("guess oldboy_age:"))
if guess_age == age_of_oldboy:
print ("yes,you got it!")
break
elif guess_age > age_of_oldboy:
print ("guess smaller...")
else:
print("guess it bigger...")
count +=1
else:
print ("your tried more than 3 times...")

#4猜年龄的游戏.循环方法02:
age_of_oldboy = 56
count = 0
for count in range(3):
guess_age = int(input("guess oldboy_age:"))
if guess_age == age_of_oldboy:
print ("yes,you got it!")
break
elif guess_age > age_of_oldboy:
print ("guess smaller...")
else:
print("guess it bigger...")
else:
print ("your tried more than 3 times...")

#5:打印循环数字:
for i in range(9):
print("______",i)
for j in range(9):
print(j)
if i > 5:
print("end!")
break

#6测试模块打印目录:
import os
cmd_res = os.popen("dir").read()
print("-->",cmd_res)
os.mkdir("new_dir")

day01学习总结(20170213)

标签:pop   popen   password   输入   long   get   pre   end   username   

原文地址:http://www.cnblogs.com/liulvzhong/p/6402518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!