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. PHP 的 SAPI 是个什么东西(转)

     SAPI,是 Server Application Programming Interface 的首字母缩写,意思是服务器端应用编程接口. 这是 PHP 内核提供给外部调用其服务的接口,即外部系统可 ...

  2. Ethernet IP TCP UDP 协议头部格式

    The Ethernet header structure is shown in the illustration below: 以太网头部14 bytes Destination Source L ...

  3. iOS Framework制作流程

    1.新建工程选择iOS —> Cocoa Touch Framework 2.进入创建好的工程删除掉自带的工程同名头文件 3.添加所需文件 4.TARGETS —> Build Setti ...

  4. GoJS实例3

    复制如下内容保存到空白的.html文件中,用浏览器打开即可查看效果 <!DOCTYPE html> <html> <head> <meta charset=& ...

  5. java执行操作系统脚本

    http://www.cnblogs.com/bencakes/p/6139477.html 以前只是知道Runtime.getRuntime().exec(command);这种用法,但是有时候命令 ...

  6. <强化学习>基于采样迭代优化agent

    前面介绍了三种采样求均值的算法 ——MC ——TD ——TD(lamda) 下面我们基于这几种方法来 迭代优化agent 传统的强化学习算法 || ν ν 已经知道完整MDP——使用价值函数V(s) ...

  7. Day5 - C - Agri-Net POJ - 1258

    Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet c ...

  8. Service总结

    Service Service的应用场景,以及和Thread区别 开启Service的两种方式以及区别 Service基础 Service是什么? Service(服务)是一个可以在后台长时间运行而没 ...

  9. 剑指offer系列(六)

    题目描述: 输入一个链表,按链表值从尾到头的顺序返回一个ArrayList,例如按照链表顺序,1->2->3->4->5->6->7->8,那么我们将得到{8 ...

  10. Golang的基础数据类型-字符串型

    Golang的基础数据类型-字符串型 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.字符型概述 上一篇博客学习了使用单引号括起来的单个字符就是字符类型,在Golang中有两种表 ...