How does pycharm add quotation marks to a string of Chinese shortcuts (method 2)

Click on " Python Crawler and Data Mining " above to pay attention

Reply to " Books " to get a total of 10 e-books on Python from entry to advanced

now

Day

chicken

Soup

The businessman paid more attention to profit than left, and went to Fuliang to buy tea the month before last.

Hello everyone, I am Pippi.

I. Introduction

A few days ago, I asked a Pycharmbasic question in the Python Silver Group [Such Creatures], and I will share it with you here.

1eed7a5359e37c9505734ce4e1290cbd.png

The original string is as follows:

str1 = "校企联合,省料学,市科学,区科学,社会料学,料学院,料学家,科学实验室,国家料学,国防料学,能源料学,生命科学,计算机料学,国家料学,研究所长,研究所副所长,研究所合作"

2. Implementation process

In the previous article, we used the string segmentation method to perfectly solve this problem. Here is a new method using regular expressions for matching and replacement.

4a62e0d83b4abe39f1943bb00cc12d8d.png

There are two details that need to be grasped here. The first is that you need to select the regular mode, and the second is that you need to pay attention to the comma in the regular expression mode must be in the Chinese mode, so that it can be matched with the original string. Otherwise, the data cannot be matched.

fdec1f464768589b924b132a4fa94f27.png

Note that there are basically no problems with these two points.

03b87f5db3da92fc8552bb1ce8aed794.png

Solved the problem of fans smoothly. There are many ways, all roads lead to Rome, as long as it can solve the problem.

3. Summary

Hello everyone, I am Pippi. This article mainly takes stock of a Pandasbasic problem. Aiming at this problem, the article gives specific analysis and code implementation to help fans solve the problem smoothly.

Finally, I would like to thank fans [such creatures] for asking questions, thank [Teacher Yuliang], [Dongge], [kim], [巭嫑勥烎] for their ideas and code analysis, and thank [冫马讠成] and others for participating in the study comminicate.

[Supplementary questions] Warm reminder, when you ask questions in the group. You can pay attention to the following points: if it involves large file data, you can desensitize the data, send some demo data (meaning small files), and then paste some code (the kind that can be copied), and remember to send the screenshot of the error report (complete cut ). If there are not many codes, just send the code text directly. If the code exceeds 50 lines, just send a .py file.

5d089c39e7ecf46ed0a10c2dc796d269.png

If you have any problems during the learning process, please feel free to contact me to solve them (my WeChat: pdcfighting1). At the request of fans, I have created some high-quality Python paid learning exchange groups and paid order receiving groups. Welcome everyone to join me Python learning exchange group and order receiving group!

037d41c65356f7c1dadeaddf5ce64b2e.png

Friends, hurry up and practice it! If you encounter any problems during the learning process, please add me as a friend, and I will pull you into the Python learning exchange group to discuss learning together.

dace21d42cf20484ab144d601c1c46df.jpeg

------------------- End -------------------

Recommendations for past wonderful articles:

ff08515860dc793e1a59df333d2e2ba5.png

Welcome everyone to like, leave a message, forward, repost, thank you for your company and support

If you want to join the Python learning group, please reply in the background [ join the group ]

Thousands of rivers and thousands of mountains are always in love, can you click [ Looking ]

/Today's Message Topic/

Just say a few words~~

Guess you like

Origin blog.csdn.net/pdcfighting/article/details/131606442