Python str() 函数


Python str() 函数

Python 内置函数 Python 内置函数


描述

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

语法

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

class str(object='')

参数

  • 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'
>>> 

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM