2019-02-18
閱讀量:
753
python str 與 repr 用法是啥?
python str 與 repr 用法是啥?
答:python可以通過(guò)使用str 與 repr 這兩種機(jī)制將值轉(zhuǎn)換為字符串。
str 能將特殊編碼轉(zhuǎn)換為相應(yīng)的字符
print(str'hello \nworld')
輸出:
hello
world
repr 能將值轉(zhuǎn)換為合法python表達(dá)式
print(repr'hello \nworld')
輸出:'hello \nworld'






評(píng)論(0)


暫無(wú)數(shù)據(jù)
CDA考試動(dòng)態(tài)
CDA報(bào)考指南
推薦帖子
0條評(píng)論
0條評(píng)論
0條評(píng)論
0條評(píng)論