repr和str

a="Hello"
print(str(a))
print(repr(a))

结果:

Hello
'Hello'

可以看出,repr的结果中多了左右两个引号。

repr和ascii

同样是返回字符串,如果是非 ASCII 编码的字符,repr()返回的是\x, \u,\U,这ascii()则不是。

repr. str, ascii in Python的更多相关文章

  1. python 打印 str 字符串的实际内容 repr(str)

    python 打印 str 字符串的实际内容 repr(str) s = 'aa' print(repr(s))

  2. The bytes/str dichotomy in Python 3

    The bytes/str dichotomy in Python 3 - Eli Bendersky's website https://eli.thegreenplace.net/2012/01/ ...

  3. Python repr, str, eval 使用小记 及 str 和 repr的区别

    >>> s = '1+2'>>> x = eval(s) #把引号剥离一次,就变成了运算1+2>>> x3>>> ss = st ...

  4. The bytes/str dichotomy in Python 3 [transport]

    reference and transporting from: http://eli.thegreenplace.net/2012/01/30/the-bytesstr-dichotomy-in-p ...

  5. 按某个属性排序(字典序,ascII) js/python

    javascrapy方法 var compare = (prop)=>{ return (a,b)=>{ : - } } javascrapy测试代码 var aaa = [ {name: ...

  6. string unicode utf8 ascii in python and js

    http://www.jb51.net/article/62155.htm http://www.cnblogs.com/dkblog/archive/2011/03/02/1980644.html ...

  7. 7. python 字符串格式化方法(2)

    7. python 字符串格式化方法(2) 紧接着上一章节,这一章节我们聊聊怎样添加具体格式化 就是指定替换字段的大小.对齐方式和特定的类型编码,结构如下: {fieldname!conversion ...

  8. Python之str()与repr()的区别

    Python之str()与repr()的区别 str()一般是将数值转成字符串,主要面向用户.  repr()是将一个对象转成字符串显示,注意只是显示用,有些对象转成字符串没有直接的意思.如list, ...

  9. python中str()和repr()的区别

    >>> s = 'Hello, world.' >>> str(s) 'Hello, world.' >>> repr(s) "'Hel ...

随机推荐

  1. SPFA和堆优化的Dijk

    朴素dijkstra时间复杂度$O(n^{2})$,通过使用堆来优化松弛过程可以使时间复杂度降到O((m+n)logn):dijkstra不能用于有负权边的情况,此时应使用SPFA,两者写法相似. 朴 ...

  2. vue - 动态绑定 class

    <template>   <div class="todo-item" :class="{'is-complete':todo.completed}&q ...

  3. NOIp2018普及组初赛试卷

    第二十四届全国青少年信息学奥林匹克联赛初赛(普及组C++语言试题)

  4. loadBeanDefinitions方法源码跟踪(二)

    因为字数超过了限制,所以分成了三篇,承接上篇: https://www.jianshu.com/p/a0cfaedf3fc5 代码过宽,可以shift + 鼠标滚轮 左右滑动查看 3.parseDef ...

  5. tp5日志分表

    /** * 记录网站日志 * * @return bool */ public function record() { // 组装数据 $log = self::$param; $log[self:: ...

  6. hook框架frida的安装以及简单实用案例

    1.下载地址 https://github.co/frida/frida/releases 2.另外两种安装方法 1.Install from prebuilt binaries This is th ...

  7. 7.9 规划Varnish缓存

    ./varnishlog -i VCL_LOG

  8. mysql concat与concat_ws区别

    select concat('大','小') as size from 表 查询出结果为:大小 select concat('大',NULL) as size from 表 查询出结果为:null c ...

  9. c# GlobalAddAtom GlobalDeleteAtom

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. P1049 数列的片段和

    P1049 数列的片段和 转跳点: