'''
This code use python urllib2 syntax
- This code use for download a page
'''
import urllib2
u="http://www.sust.edu"
f = urllib2.urlopen(u)
data=f.read()
f.close()
print data;
Thursday, October 28, 2010
Python fetch URL
Posted by
Abu Zahed Jony
at
3:39 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
Url Fetch
Python Threading Use A Thread Class
'''
This code use a thread class
- Save this class named 'AnyName.py'
- Run this code you need class 'ThreadClass.py'
'''
import ThreadClass
for i in range(1,4):
threadObject=ThreadClass.ThreadClass(i)
threadObject.start()
Output:
output: output: 1output: 23 output: 1 output: 2output: 3 output: 1 output: output: 32
Posted by
Abu Zahed Jony
at
3:10 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
Thread
Python Threading
'''
This code use python threading syntax
- Save this class named 'ThreadClass.py'
'''
import threading
import time
class ThreadClass(threading.Thread):
def __init__(self,data):
threading.Thread.__init__(self)
self.data=data
def run(self):
for i in range(0,3):
print "output: ",self.data
time.sleep(1);
Posted by
Abu Zahed Jony
at
3:07 AM
0
comments
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels:
Object-oriented programming,
Thread
Subscribe to:
Comments (Atom)
