Here's the thing, I wanna change some wrong words from a text file like this:
"I am a studaet." -> "I am a student."
I have tried to use this command:
str = "I am a studaet."
newstr = str[0:8] + "ent"
print newstr
But the system said TypeError: 'type' object is unsubscriptable
What's wrong
On 3/28/2010 2:23 PM Shurui Liu (Aaron Liu) said...
Here's the thing, I wanna change some wrong words from a text file like this:
"I am a studaet." -> "I am a student."
I have tried to use this command:
str = "I am a studaet."
newstr = str[0:8] + "ent"
print newstr
But the system said Ty
>>> s = "I am a studaet."
>>> new_s = s[0:8] + 'ent'
>>> print new_s
I am a sent
You are using str as a variable, str is used to convert anything into string
>>> a = 0
>>> b = str(a)
>>> type(b)
On Mon, Mar 29, 2010 at 2:53 AM, Shurui Liu (Aaron Liu)
wrote:
> Here's the thing, I wanna change
Tell me how to do what i want, please.
2010/3/28 Shashwat Anand :
s = "I am a studaet."
new_s = s[0:8] + 'ent'
print new_s
> I am a sent
>
> You are using str as a variable, str is used to convert anything into string
>
a = 0
b = str(a)
type(b)
>
>
>
> On Mon, Mar 2
On 28 March 2010 23:37, Shurui Liu (Aaron Liu) wrote:
> Tell me how to do what i want, please.
>
Both me and someone else have already told you how to replace a substring in
a string with something else in your earlier question/posting/thread. If
you've not understood what was written there, th