Skip to content

Instantly share code, notes, and snippets.

@Celia-code
Created April 21, 2020 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Celia-code/d68471428e1bc87d66de48cb96f55fc0 to your computer and use it in GitHub Desktop.
Save Celia-code/d68471428e1bc87d66de48cb96f55fc0 to your computer and use it in GitHub Desktop.
字符串
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