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.





    附件列表

  • 相关阅读:
    bootstrap模态框
    css 禁止选中文本
    Python Flask Tornado
    JS canvas标签动态绘制图型
    JS 跳转页面
    JS 计算器
    JS
    柱状图中最大的矩形
    在不使用第三个变量的情况下交换两个数的值
    springboot配置静态资源访问的2种方式
  • 原文地址:https://www.cnblogs.com/dabiao/p/4516216.html
Copyright © 2011-2022 走看看