3.265 参考/repr() 函数

Python repr() 函数

描述

repr() 函数将对象转化为供解释器读取的形式。

语法

以下是 repr() 方法的语法:

repr(object)

参数

  • object -- 对象。

返回值

返回一个对象的 string 格式。

实例

以下展示了使用 repr() 方法的实例:

>>>s = 'NOWCODER'
>>> repr(s)
"'NOWCODER'"
>>> dict = {'nowcoder': 'nowcoder.com', 'google': 'google.com'};
>>> repr(dict)
"{'google': 'google.com', 'nowcoder': 'nowcoder.com'}"
全部评论

相关推荐

没hc还海面!呜呜,避雷
回收旧报纸:没有海面吧,我做完笔试有一个多月了,还没消息
点赞 评论 收藏
分享
已注销:bro不如吃顿疯狂星期四
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务