定義
str()將對象轉換為適合閱讀的字符串形式。
語法
class str(object='')
參數
- object -- 對象。
返回值
返回一個對象的string格式。
實例
1 s = 'RUNOOB' 2 print(str(s)) # 輸出RUNOOB 3 dict = {'runoob': 'runoob.com', 'google': 'google.com'} # 輸出{'runoob': 'runoob.com', 'google': 'google.com'} 4 print(str(dict))
參考網址
- Python str() 函數:https://www.runoob.com/python/python-func-str.html