selfteaching / selfteaching/selfteaching-python-camp

Day05 关于字符串查找与替换的一个问题

Open
#3,431 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

在看到字符串的搜索与替换,这一部分的时候,从str.startswith()和str.endswith()开始为什么代码就要重复写2行呢?当然是稍微有些区别的,区别在于第2行代码不用加双引号“”和冒号:了,且被第1行代码用脱字符\隔开了。
就像这样:
关于查找与替换的问题2
还有在替换的时候str.replace的时候,也是这个情况。明明在查找的时候还是一行代码就可以表示,到了这里为什么要写两遍,才能最终显示呢?
关于字符串查找与替换的一个问题

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue refers to the Day05 string search-and-replace lesson and examples using str.startswith(), str.endswith(), and str.replace(). Start by locating that lesson and reviewing the referenced examples and images; done means the lesson clearly explains the repeated lines and differing syntax. No repository file or test is named in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.