python输入和输出

  输入:print

    在3.0+中print以函数的形式处理。

      e.g.:print("Hello world!")

  输出:input()

  

  例子:

    例1:

    print('please enter your name:')

    input();

    输出结果:

      please enter your name:

      ”等待输入内容“

 

    例2:

    name=input('please enter your name:')

    print('Hello', name)

    输出结果:

      please enter your name:name

      “等待输入内容”

 

      Hello name

 

   占位符:

    整数:%d

    浮点数:%f

    字符串:%s

    十六进制数:%x

      e.g. print ' name : %s\n age : %d\n sex : %d' %  ('yuan', '22', '1')

      %运算符是用来格式化字符串的。

 

 

 

  

posted @ 2017-09-21 13:01  insistYuan  阅读(107)  评论(0)    收藏  举报