zoukankan      html  css  js  c++  java
  • 学习笔记-20150519

    字符串的合并和占位符的使用
    注意在%号前不能有引号。

    Image.png

    1.  1 # -*- coding:utf-8 -*-
       2 my_name ='中国'
       3 my_age =35
       4 my_height =74
       5 my_weight =180
       6 my_teeth ='White'
       7 my_hair ='Brown'
       8 print("Let's talk about %s."% my_name)
       9 print("He's %d inch tall, %s"%(my_height, my_name))
      10 #test注意
      11 print("Let's add my height %d to my weight %d,and get the result: %d"%(my_height,my_weight,my_height+my_weight))

    另一个例子:

    1.  1 x ="There are %d types of people"%10
       2 binary ="binary"
       3 do_not ="don't"
       4 y="Those who know %s and those who %s."%(binary,do_not)
       5 print x
       6 print y
       7 print"I said:%r"%x
       8 print"I also said: '%s'."% y
       9 hilarious =False
      10 joke_evaluation ="Isn't that Joke so funny?! %r"
      11 print joke_evaluation %hilarious
      12 w="This is the left side of ..."
      13 e="a string with a right side."
      14 print w+e

    运行结果:

    There are 10 types of people
    Those who know binary and those who don't.
    I said:'There are 10 types of people'
    I also said: 'Those who know binary and those who don't.'.
    Isn't that Joke so funny?! False
    This is the left side of ...a string with a right side.





    附件列表

  • 相关阅读:
    三层架构之解耦
    自动升级 组件
    C语言常量与指针
    ASP.NET MVC Model元数据
    Web层后端权限模块
    java中文排序问题(转)
    JDWP
    bat执行java程序的脚本解析
    jdom dom4j解析xml不对dtd doctype进行验证(转)
    Dom4j SAXReader Constructors
  • 原文地址:https://www.cnblogs.com/dabiao/p/4516216.html
Copyright © 2011-2022 走看看