初学Python之字符串操作

Posted on 2016-11-07 18:41  哇好大哦  阅读(157)  评论(0编辑  收藏  举报

字符串.replace()

phone_number='158-8888-8888'

hide_number=phone_number.replace(phone_number[:9],'*'*9)

 

字符串.format()

____a word she can get what she ____ for.

A.With B.came

'{}a word she can get what she{}for.'.formate('with','came')

'{0}a word she can get what she{1}for.'.formate('with','came')

'{prepostion}a word she can get what she{verb}for.'.formate(prepostion='with',vreb='came')

Copyright © 2024 哇好大哦
Powered by .NET 8.0 on Kubernetes