3.284 参考/str() 函数

Python str() 函数

描述

str() 函数将对象转化为适于人阅读的形式。

语法

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

class str(object='')

参数

  • object -- 对象。

返回值

返回一个对象的string格式。

实例

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

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

相关推荐

评论
点赞
收藏
分享

创作者周榜

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