Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit603b8ca

Browse files
committed
new file: expand/2.py
1 parentd4f7f2f commit603b8ca

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+
importre
9+
defprintReplace(srcStr,word):
10+
forletterinsrcStr:
11+
ifletter==word:
12+
srcStr=srcStr.replace(letter,'!')#字符串不可更改
13+
returnsrcStr
14+
15+
defprintReplace_re(srcStr,word):
16+
srcStr=re.sub(word,'!',srcStr)
17+
returnsrcStr
18+
19+
defmain():
20+
srcStr=raw_input(u"请输入一个字符串:")
21+
destStr=printReplace_re(srcStr,'i')
22+
printdestStr
23+
24+
25+
if__name__=="__main__":
26+
main()
27+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp