新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
創(chuàng)新互聯(lián)Python教程:python中str()函數(shù)轉(zhuǎn)換字符串
1、方法說(shuō)明

超過(guò)十載行業(yè)經(jīng)驗(yàn),技術(shù)領(lǐng)先,服務(wù)至上的經(jīng)營(yíng)模式,全靠網(wǎng)絡(luò)和口碑獲得客戶(hù),為自己降低成本,也就是為客戶(hù)降低成本。到目前業(yè)務(wù)范圍包括了:成都做網(wǎng)站、成都網(wǎng)站制作,成都網(wǎng)站推廣,成都網(wǎng)站優(yōu)化,整體網(wǎng)絡(luò)托管,微信小程序開(kāi)發(fā),微信開(kāi)發(fā),APP應(yīng)用開(kāi)發(fā),同時(shí)也可以讓客戶(hù)的網(wǎng)站和網(wǎng)絡(luò)營(yíng)銷(xiāo)和我們一樣獲得訂單和生意!
如果只是想把python的對(duì)象轉(zhuǎn)換成文字串的話(huà),str()函數(shù)是回到人類(lèi)可讀值的表示。
2、語(yǔ)法
class str(object='')
3、實(shí)例
>>> s = 'Hello, world.'
>>> str(s)
'Hello, world.'
>>> repr(s)
"'Hello, world.'"
>>> str(1/7)
'0.14285714285714285'
>>> x = 10 * 3.25
>>> y = 200 * 200
>>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'
>>> print(s)
The value of x is 32.5, and y is 40000...
>>> # The repr() of a string adds string quotes and backslashes:
... hello = 'hello, world\n'
>>> hellos = repr(hello)
>>> print(hellos)
'hello, world\n'
>>> # The argument to repr() may be any Python object:
... repr((x, y, ('spam', 'eggs')))
"(32.5, 40000, ('spam', 'eggs'))"以上就是python中str()函數(shù)轉(zhuǎn)換字符串的方法,希望對(duì)大家有所幫助。更多Python學(xué)習(xí)指路:創(chuàng)新互聯(lián)python教程
新聞標(biāo)題:創(chuàng)新互聯(lián)Python教程:python中str()函數(shù)轉(zhuǎn)換字符串
網(wǎng)頁(yè)路徑:http://m.fisionsoft.com.cn/article/cdgecij.html


咨詢(xún)
建站咨詢(xún)
