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