selfteaching / selfteaching/selfteaching-python-camp
Day10 关于汉字词语长度大于2的坑,以及请问为什么.remove函数无效?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
一直想偏了,觉得汉字要经过编码,根据不同的编码方式,一个汉字的长度至少是2个字节,所以想2个汉字应该长度至少为4,实际上程序在统计汉字词语长度的时候,是将一个汉字长度计算为1的!另外我最初的设想是用遍历判断每个词语的长度,如果小于2 就把该元素删除,用的是 list.remove(i)命令,但是报错'generator' object has no attribute 'remove',请问这是什么原因?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by locating the code that counts Chinese word lengths and creates the generator, then reproduce both behaviors with a minimal Python example. Done means documenting why characters count as length 1 and why remove is unavailable on a generator.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100