Python str() 函数

更新时间:2022-01-16 13:45
描述

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


语法
以下是 str() 方法的语法:
1
class str(object='')

参数
  • object -- 对象。

返回值

返回一个对象的string格式。


实例
以下展示了使用 str() 方法的实例:
1
2
3
4
5
6
7
>>>s = '995w'
>>> str(s)
'995w'
>>> dict = {'995w': '995w.com', 'google': 'google.com'};
>>> str(dict)
"{'google': 'google.com', '995w': '995w.com'}"
>>>