string.replace() produces TypeError: an integer is required

theKid cmlambert at hotmail.com
Wed Mar 12 02:56:10 EST 2003


As far as I can tell, I'm using the function correctly:

                import string
                import types

                print type(data)
                print data
		data = string.replace(data, '\t', '\\t')             # line 58
		data = string.replace(data, '\n', '\\n')
		print data

Output:

  <type 'str'>
HI      THERE
Traceback (most recent call last):
  File "./2_sm_client.py", line 58, in ?
    data = string.replace(data, '\t', '\\t')
TypeError: an integer is required

This is with Python 2.2.2

Am I using string.replace() correctly?

TIA

Craig




More information about the Python-list mailing list