selfteaching / selfteaching/selfteaching-python-camp

Day6 怎样将文档中所有的特殊字符都去除呢?

Open
#5,887 2 comments 1 reaction 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

  1. text = input('请输入你要处理的文档:')
  2. def stats_text_en(text):
  3.     text=text.replace('!',' ') #面对待处理的文档,没办法把可能出现的特殊字符都遍历一边然后替换,如果使用.isalpha()的话会把空格都删掉,该怎么办呢?
  4.     text=text.lower()
  5.     text=text.split()
  6.     dict1={}
  7.     for i in text:
  8.         j=text.count(i)
  9.         dict2={i:j}
  10.         dict1.update(dict2)
  11.         dict2=sorted(dict1.items(),key=lambda x:x[1],reverse=True)
  12.     print(dict2)
  13. stats_text_en(text)

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

Start with the stats_text_en entry point shown in the issue body and review how its input is split and counted. Confirm which special characters should be removed and how whitespace should be preserved, then verify that the resulting frequency output matches that behavior. No repository file or test is identified in the payload.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
content
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.