Python 內(nèi)置函數(shù),str() 函數(shù)將對象轉(zhuǎn)化為適于人閱讀的形式。
Python 內(nèi)置函數(shù)
描述
str() 函數(shù)將對象轉(zhuǎn)化為適于人閱讀的形式。
語法
以下是 str() 方法的語法:
class str(object='')
參數(shù)
object -- 對象。
返回值
返回一個對象的string格式。
實例
以下展示了使用 str() 方法的實例:
>>>s = 'RUNOOB' >>> str(s) 'RUNOOB' >>> dict = {'runoob': 'runoob.com', 'google': 'google.com'}; >>> str(dict) "{'google': 'google.com', 'runoob': 'runoob.com'}" >>>