Arrgh! Please help.
Cliff Crawford
cjc26 at nospam.cornell.edu
Sat May 13 22:15:36 EDT 2000
* chibaA at TinterlogD.Tcom <chibaA at TinterlogD.Tcom> menulis:
| I'm pulling my hair out as to why I get this error:
|
| For this code:
| if 1:
| print "Content-Type: text/html\n\n"
| print "whatever",
| oL = ""
| for key,value in rv.items():
| oL = oL + value + "&" + "blah"
| print "blah",
| print "=",
| print oL
|
| I get this result:
| Traceback (innermost last):
| File "./update_user.py", line 58, in ?
| oL = oL + value + "&" + "blah"
| TypeError: illegal argument type for built-in operation
|
| WHY??? It seems like it maybe trying to add the variables & elements
Looks like the values in rv are not strings. How is rv defined?
| like numbers... but I don't know another way to glue together a
| string.
You can use the % operator. Instead of
oL = oL + value + "&" + "blah"
you can write
oL = oL + "%s&blah" % value
The "%s" means that the value of the variable value will be inserted
into the string at that point as a string.
| And while I'm at it, is there any way to use consecutive print
| statements, and NOT have spaces in the output? ( I know comma gets rid
| of the \n, but not the spaces).
Use sys.stdout.write() instead.
--
cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/
"One man's nirvana is another man's map." icq 68165166
More information about the Python-list
mailing list