靳闯博客 记录是一种习惯,分享是一种态度
  • 波浪
  • 波浪
  • 波浪
  • 波浪
python2.x 3种变量形式调用
发表于: | 分类: 技术积累 | 标签: python | 评论:0 | 阅读: 162

python 变量使用

raw_input 2.x = input 3.x


第一种

name = input("name:")
age = input("age:")
job = input("job:")

info = '''
----------info - %s ----------
Name: %s
Age: %s
Job: %s
'''% (name,name,age,job)
print (info)

第二种

name = input("name:")
age = input("age:")
job = input("job:")
info = '''
----------info - {0} ----------
Name: {0}
Age: {1}
Job: {2}
'''.format(name,age,job)
print (info)

第三种

name = input("name:")
age = input("age:")
job = input("job:")
info = '''
----------info - {name} ----------
Name: {name}
Age: {age}
Job: {job}
'''.format(name=name,
       age=age,
       job=job)
print (info)


如果这篇文章帮助到了你,我感到十分荣幸!

或许你不想写点什么......

icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif

站点地图 网站地图
豫ICP备17003270号 | Copyright © 2017-2018 💖 靳闯博客
Typecho🍹Sgreen
TOP