编程语言
首页 > 编程语言> > Python str() 函数

Python str() 函数

作者:互联网

Python str() 函数

Python 内置函数 Python 内置函数


描述

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

语法

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

class str(object='')

参数

返回值

返回一个对象的string格式。


实例

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

>>> s = 'RUNOOB'
>>> str(s)
Traceback (most recent call last):
  File "<pyshell#86>", line 1, in <module>
    str(s)
TypeError: 'str' object is not callable
>>> dict = {'runoob':'runoob.com','google':'google.com'};
>>> str(dict)
Traceback (most recent call last):
  File "<pyshell#88>", line 1, in <module>
    str(dict)
TypeError: 'str' object is not callable
>>> import str
Traceback (most recent call last):
  File "<pyshell#89>", line 1, in <module>
    import str
ModuleNotFoundError: No module named 'str'
>>> 

  

标签:Traceback,函数,Python,object,call,str,recent
来源: https://www.cnblogs.com/mzasdcr/p/15501277.html