码迷,mamicode.com
首页 > 编程语言 > 详细

PYTHON拼接显示循环和判断学习

时间:2017-05-21 09:49:22      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:style   log   转义   ldb   break   conf   blog   inpu   span   

拼接显示:

name = input("name:")
age = int(input("age:"))#转义成整数
job = input("job:")
salary = input("salary:")

info = ‘‘‘
----------in of   %s--------
Name:%s
age:%s
job:%s
salary:%s
‘‘‘ %(name,name,age,job,salary)
%s 字符串   %d整数

info1 = ‘‘‘
----------in of {_name}-----------
Name:{_name}
age:{_age}
job:{_job}
salary: {_salary}
‘‘‘.format(_name=name,
           _age=age,
           _job=job,
           _salary=salary)

info3 = ‘‘‘
----------in of {0}--------
Name:{0}
age:{1}
job:{2}
salary:{3}
‘‘‘ .format(name,age,job,salary)

print(info)
print(info1)
print(info3)

简单的循环,判断

guess_age_oldboy = 56
count = 0
while count <3:
    guess_age = int(input("guess age:"))
    if guess_age == guess_age_oldboy:
        print("YES,YOU GOT IT.")
        break
    elif guess_age > guess_age_oldboy:
        print("think 大了r..")
    else:
        print("think,小了")
    count +=1
    if count == 3:
        countine_confirm = input("你还想玩吗?")
        if countine_confirm !=n:
            count=0
else:
    print("你太蠢了。。。。")

 

PYTHON拼接显示循环和判断学习

标签:style   log   转义   ldb   break   conf   blog   inpu   span   

原文地址:http://www.cnblogs.com/ljs1120/p/6883896.html

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