【Python】python的各种函数

 今日学了:

 

1.%s 表字符串

   %d表数字

 

2.【print"He's got %s eyes and %s hair." %(my_eyes,my_hair)】

    多个变量时要用括号

    运行结果是:He's got Bule eyes and Brown hair.

    如果改成用%r,则会有单引号显示。

    运行结果是:He's got 'Bule' eyes and 'Brown' hair.

 

3.【all of the Python format characters

(1):Fancier Output Formatting:http://docs.python.org/2/tutorial/inputoutput.html#fancier-output-formatting

(2):String Formatting Operations:http://docs.python.org/2/library/stdtypes.html#string-formatting

 

4.

     str()一般是将数值转成字符串。 
     repr()是将一个对象转成字符串显示

 

 

  

posted on 2012-10-26 20:45  Jenny_HUI  阅读(180)  评论(0编辑  收藏  举报

导航