15,190 Topics
![]() | |
Hi, I'm trying to use regular expressions on a log file and am trying to extract search terms. Each line in the file is of the form: [CODE]mystring = "00:00:11 192.168.21.44 GET /images/help.gif - 200 Mozilla/4.0+(compatible;+MSIE+5.0;+Windows+98;+DigExt) ASPSESSIONIDGGGGGQEG=CLDIHIJBJAPFAGBFIOMCFGGA;+PRO%5FOnline=SEARCHQUERY=%09%3Cinput+type%3Dhidden+name%3D%27HrowColumns%27+ID%3D%27HrowColumns%27++value%3D%271%3B6%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData10%27+ID%3D%27txtScopeData10%27++value%3D%27[COLOR="Red"]catherine[/COLOR]%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData30%27+ID%3D%27txtScopeData30%27++value%3D%27[COLOR="Red"]porter[/COLOR]%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData50%27+ID%3D%27txtScopeData50%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData11%27+ID%3D%27txtScopeData11%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData31%27+ID%3D%27txtScopeData31%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData51%27+ID%3D%27txtScopeData51%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27HCollection%5Fid%27+ID%3D%27HCollection%5Fid%27++value%3D%271%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27Submit1%2Ex%27+ID%3D%27Submit1%2Ex%27++value%3D%2736%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27Submit1%2Ey%27+ID%3D%27Submit1%2Ey%27++value%3D%2718%27%3E%0D%0A http://www.foo-bar.com/SearchResult.asp"[/CODE] I have put the search terms that I'm trying to extract above … | |
Regex is one of the more complicated modules that you can use in python. Once you have learnt it though you can use it many different programming languages, so its a useful tool for using with strings. So first to use regex you must import it [code] import re [/code] … | |
im new to python, been working in php largely in the past, but wanted to learn something new and different. as such, i want to use python to create webpages, but have been tinkering in the IDLE until now... when using php, I use a local install of WAMP... is … | |
Hey guys, I have a already written package in python2.5.1 for windows,it includes wxpython biopython1.44 modules and now i want to transfer it to unix server,is there any way i can do that or i have to write that functions again...\ Thanks in advance Prankyrules | |
Hi there i am new at OOP and i want learn about it. I start with the book how to think like a computer scientist but at the ending chapters i get lost .... Can some one advice me a good book that covers OOP ?with good examples,diagrams e.t.c. | |
Hello. I would like to open and read OO Writer. I used the script: [file = open('myfile.odt', 'r'] [lines = file.readlines()] [file.close()] [for i in lines: print i] I get some strange characters. I had write 'rb', instead 'r', but it did not work. I have copied a ODT file … | |
Alright guys so I have a little problem with a nested list. so here is my list: [code=python] a = [[1,2,3], [4,5,6], [7,8,9]] #I know that I can do for example a[0][0] and that will return the first value in the first nested list but I don't know how to … | |
Hi, My code requires to send an email to list of people that satisfy certain conditions. This email will in turn have a hyperlink to open another email,with subject and body pre populated. When I try creating this hyperlink, i want the code to be hidden ie. i want to … | |
Hey, I'm trying to make a program restart if a function (in this case playAgain) is true. Is there a simple way to do this? Here's the end of my program: [CODE=python]theGame() if playAgain() == True: else: quit()[/CODE] | |
I have a little program that goes to news aggregater's, gets the hrefs, and returns in a window. I want to have multiple windows open if multiple sites are choosen, right now, it will only go to the first one in a list, and completes perfectly. I assume I am … | |
how could I make the function count?.. its a test marked out of 5, so if the user enters 1,1,2,2,4,5, then the output= 2 people got 1 mark, 2 people got 2 marks and 0 got 3 marks and so on?... i dnt knw if my code is even right.. … | |
response = urlopen("https://www.lingq.com/accounts/login/") #response = urlopen("http://www.google.com.vn") window = ParseResponse(response) window.document # HTML DOM Level 2 HTMLDocument interface forms = window._htmlforms # list of objects supporting ClientForm.HTMLForm i/face form = forms[1] print form #print form control = form.find_control("password") form["password"] = 'password' control = form.find_control("username") form["username"] = 'username' response2 = urlopen(form.click()) for … | |
I try again in a new thread, the other went out of hand. I use this code line to create a n value. n = random.randint(0, 99), i use this n value as a lap index to my while loop. The loop is in a function called "def run(self)" in … | |
I'm just wondering if it is possible to import a module as an object attribute. The basic description of what I want to accomplish is that I'm creating a software agent object. This agent will have a set of abilities (functions), but I don't know what these are ahead of … | |
Hi,there, assert pop == "berg", "Item removed from the stack was not \"berg\"." why using '...' can avoid syntax error ? Thank you :) | |
Hi, Sorry if this is already asked, but I couldn't find it. I got a text file with 100010101001000010000011111001010 and it is 8bit, now I would like it to decimal. With the int(file,2) function it does not work. I get a very large number. Is there an extra command I … | |
How would you make a simple bar graph from a list of data? [code]data = [20, 15, 10, 7, 5, 4, 3, 2, 1, 1, 0] [/code] | |
Hello, I'd like to get help for a database engine in Python. I know that there are loads of databases out there and I cannot create one which would be even near as good as SQL but I'd like to do it for getting a good understanding of databases and … | |
How do i reach a class from within another class? I have Class A and Class B How can i activate or run class A from Class B? example, if class A and class B work toward the same resource, one create data the other consume data. How can i … | |
Hello my name is Mikal. I am working on some python code, and it is now at the point where it does what I want, but its not quite fast enough for my liking. Here is my current code that works: [code=python] self.timersVS = {'combat':0,'regen':0} ... # Tick Timers and … | |
Hi guys i was wondering how in python you invert this line as I have indicated. I have tried all sorts of mathemtical functions. I am using zelle graphics module. Currnetly I have produced lines going in one direction im trying to produce the same lines again but in the … | |
i have created lines in graphwin but i did it the long way is there a simpler way using loops ? cheers | |
im completely new to python and not particularly experienced with anything that isnt running off of a web server... Im reading 'A byte of Python' and while my first shell script worked, which was just the 'Hello world', but if I create a separate file and have saved it within … | |
I've been writing a Python module which contains a few classes. As I have come to use the module in earnest it has become clear that I need to create a _very_ large number of instances of these classes. This is using more memory than I would like. Speed is … | |
Hi, Below is the snippet from my script which is working fine [CODE=python]if system is 'Conferences': assignedtomatrix[system]['Third'] = 'name'[/CODE] I have to now introduce one more loop checking, but could not find a way to do this. I have tried: [CODE]if system is 'Conferences': person = ['person1', 'person2', 'person3'] community … | |
I'm completely new to Python, just started going through the tutorial at python.org but am getting compile errors in places that should not be errors. I've installed Python version 3.1 on a Windows 7 machine, but I don't see any documented compatability issues. For an example, here's some simple sample … | |
hello, Pls can anybody help me with a folloving exercise? (I must say that I am really beginer in this field, learning by myself and with daniweb (if sb gives me help)) Pompt the user to enter a string of forbidden letters and also to enter a words. Make a … | |
Hi everyone! I would like to make an Air Hockey game in pygame. I was wondering if it was possible to have 'proper' bouncing (ie. the puck goes in a direction relative to the angle the paddle hit it in). I can easily write the rest of the code. Thank … | |
Not sure what I've done wrong here tried lots of alternative combinations and not sure why this logic doesn't work! Im pretty sure it has something to do with the parameter not reading as the results inputted aren't going through the loop. Any help would be appreciated! The idea of … | |
I posted a thread labeled pygame, global name "glob" but am unable to resolve the issue so I was just going to ask a few question about the code. Well first of all, I ran it on Windows Vista, python 2.6 and pygame, but I'M not sure what version of … |
The End.