Click to See Complete Forum and Search --> : Python help please


digitalzero
04-15-2003, 09:43 PM
I'm just learning python now and my first task is to make a hits counter for my web page.

What i want to do in python is read from a file that only has a number. Increment that number.
Write to that file with the new number.

So far to read from a file i'm doing this:

<code>
#!/usr/local/bin/python
counterFileStream=open('count.txt','r')
count=counterFileStream.read()
newCount=count+1
</code>

I cant perform the last line, i dont know how to cast a string to an integer.
Anyone know how?

ineedit
04-15-2003, 09:56 PM
Try

newCount=int(count)+1
or
newCount=float(count)+1