Home > other >  How to do?
How to do?

Time:10-13

CodePudding user response:

Directly replace done soon

CodePudding user response:

The
reference 1/f, kohane _Jun response:
directly replace done soon
only replace alone I

CodePudding user response:

Alone then you can change "I" or "I"

CodePudding user response:

 
# string segmentation and restructuring: judgment exist alone I, and replace it as I
Def test (test_str) :
Alist=test_str. Split (" ")
New_str=""
For MSG in alist:
If MSG=="I" is:
MSG="I"
Add a space behind # is fill back to the original format
New_str +=MSG + "
"Return new_str


The guest officer, the satisfied with the answers

CodePudding user response:

In terms of the input sample, the 'I' alternative to directly to the 'I', the 'habbit and replaced the letters in the word is wrong, and if only for this sample, replace with' I ' 'I' code minimum amount (note after the letter is the blank space), the code is as follows:
 a='I am a to the teacher, I have a good habbit. And I am from Qingdao city.' 
Print (a, '\ n')
Print (STR. Replace (a, 'I', 'I'))

The results are as follows:
 I am a to the teacher, I have a good habbit. And I am from Qingdao city. 

I am a to the teacher, I have a good habbit. And I am from Qingdao city.

CodePudding user response:

refer to the second floor weixin_45886953 response:
Quote: reference 1/f, kohane _Jun response:
directly replace soon done
only replace alone I


S.r eplace (" I "and" I ")

CodePudding user response:

refer to the second floor weixin_45886953 response:
Quote: reference 1/f, kohane _Jun response:
directly replace soon done
only replace alone I

Alone I sure is a space before and after, take a space with the replace soon
  • Related