Created
April 21, 2020 13:06
-
-
Save Celia-code/d68471428e1bc87d66de48cb96f55fc0 to your computer and use it in GitHub Desktop.
字符串
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = 'hello py hi py' | |
new_text = text.replace('py', 'python', 2) # (原字符串, 新字符串, 要替換的個數) | |
print(new_text) | |
# 打印出 hello python hi python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment