3.2.5.5 words in one sentence are randomly arranged, and 3.2.5.5 words are arranged in one sentence
Now let's play a text game. Here is a sentence for you. Apart from the first character and the last character, the internal characters can be randomly queued. This game uses regular expressions to make it easier.
Example:
Import random text = 'Building Shenzhen into a global software center. This is the new beginning. 'def repl (m): inner_word = list (m. group (2) random. shuffle (inner_word) return m. group (1) + "". join (inner_word) + m. group (3) print (text) print (re. sub (r "(\ w) (\ w +) (\ w)", repl, text ))
The output is as follows:
Building Shenzhen into a global software center is a new start
The new starting point is to make the soft, deep, and full-blown products a ball in the middle.
Here, we mainly use the re. sub function to find grouping sentences, and place the intermediate characters in the repl function for computation. Then, we return and replace the entire string.
Cai junsheng QQ: 9073204 Shenzhen
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.