| Reply | « Previous Thread | Next Thread » |
|
Hi All,
i have a little program that gets a url from urllib and saves the html content to a file. i then want to search for certain words in that file. here is my code to search for the words. Code:
list = ["yes","no","maybe"]
for i in range(0,len(list)):
f = file(u"c:\\Users\\Desktop\\test3.txt", "r")
for line in f:
if list[i] in line:
score = score + 1
i = i + 1
The error i get is: if list[i] in line: Type error: 'in<string>' requires character as left operand. Any help?? Thank you. i dont know why it works in PyDev but not on emulator ![]() |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
|
Quote:
The error is due to the fact that PyS60, unlike Python, can't determine if a string is in a string (I don't know why), only if a character is in a string. I've come up with this alternative, I hope it helps: Code:
list = ["yes","no","maybe"]
for i in range(len(list)):
f = file("c:\\python\\test3.txt", "r")
for line in f:
j=0
while(j<=len(line)):
if((list[i]==line[j:j+2]) or (list[i]==line[j:j+3]) or(list[i]==line[j:j+5])):
score+=1
j+=1
You may adapt it to the needs of your program. |
|
Thank you i will try get it to suit my application in future.
One more question.. im about to attempt to implement some sort of user profile recognition for my app. i dont want a login screen or anything like that but what way would you gifted pys60 developers recommend for keeping track of who is using the app and when etc. Database is obvious choice.. or is it?? Thank you all again. |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
|
Quote:
i have a idea to track the apps one is using we can take a snapshots which must be running in the background of the actual application. the snapshots will be stored automatically in the phone. and after analysing that snapshots one can easily know trace one. hope u r satisfied plz give a feedback. thanx ![]() ![]() Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
|
Quote:
A database is a good idea. You might try a simple approach, like writing the times at which the application is opened/closed in a text file. And if you make a login screen, you can add the user names to the text file too.
Last edited by bogdan.galiceanu : 2008-03-26 at 06:18.
|
|
Quote:
Best Regards Croozeus |
|
Thanks again!
You guys really helping me with learning to use pys60. Really appreciate it. selection list seems like a good idea ![]() |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| newbie here... need help... | maalvin15 | General Symbian C++ | 3 | 2007-11-12 01:48 |
| newbie Carbide questions | pollyp | Carbide.c++ IDE and plug-ins | 2 | 2007-10-09 23:42 |
| Newbie Bluetooth GPS Trouble | ajr | General Discussion | 2 | 2007-03-06 15:55 |
| newbie in trouble with invoking php page | gorbius | Mobile Java General | 3 | 2006-04-21 01:54 |
| Need help newbie in big trouble | tonysmiff | General Symbian C++ | 1 | 2004-01-21 11:18 |