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