zoukankan      html  css  js  c++  java
  • repr()输出转义字符

    repr()产生一个解释器易读的表达形式。

    repr() 函数可以转义字符串中的特殊字符。
    repr() 的参数可以是 Python 的任何对象。
     
     
    示例1:
    hello = 'hello, runoob '
     
    print (hello)
    输出( 表示换行,所以会输出第二行空行):
    hello, runoob
     
    print repr(hello) 
    输出(不会输出空行):
    'hello, runoob '
     
     
    示例2:
    x=1.0
    y=2.2
    hello = 'hello, runoob '
     
    print repr(x, y, ('Google', 'Runoob'),hello)
    报错:
    TypeError: repr() takes exactly one argument (4 given)
    注意输出参数多于1个时要多加一个双括号。
     
    print repr((x, y, ('Google', 'Runoob'),hello))
    输出:
    (1.0, 2.2, ('Google', 'Runoob'), 'hello, runoob ')
     
     
  • 相关阅读:
    mysql 主从配置 读写分离
    interface接口
    http结构
    call_user_func函数
    pcntl_fork 进程
    数据库事务
    php 之 ob缓冲
    shell脚本
    php 守护进程
    ssdb zset
  • 原文地址:https://www.cnblogs.com/myshuzhimei/p/11757058.html
Copyright © 2011-2022 走看看