Skip to content

Commit 603b8ca

Browse files
committed
new file: expand/2.py
1 parent d4f7f2f commit 603b8ca

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

expand/2.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#s = raw_input()
2+
#i = 0
3+
#for i in s:
4+
# print i
5+
#raw_input()
6+
7+
#扩展成在字符串中把特定字符替换成规定字符
8+
import re
9+
def printReplace(srcStr,word):
10+
for letter in srcStr:
11+
if letter == word:
12+
srcStr = srcStr.replace(letter,'!') #字符串不可更改
13+
return srcStr
14+
15+
def printReplace_re(srcStr,word):
16+
srcStr=re.sub(word,'!',srcStr)
17+
return srcStr
18+
19+
def main():
20+
srcStr = raw_input(u"请输入一个字符串:")
21+
destStr=printReplace_re(srcStr,'i')
22+
print destStr
23+
24+
25+
if __name__ == "__main__":
26+
main()
27+

0 commit comments

Comments
 (0)