This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spam = 0.0 | |
Count = 0 | |
fname = raw_input("Enter file name: ") | |
try: | |
fh = open(fname) | |
except: | |
print "File cannot be opened:",fname | |
exit () | |
for line in fh: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fname = raw_input("Enter file name: ") | |
fh = open(fname) | |
lst = list() | |
for line in fh: | |
for word in line.split(): | |
if word not in lst: | |
lst.append(word) | |
lst.sort() | |
print lst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = raw_input("Enter file:") | |
if len(name) < 1 : name = "mbox-short.txt" | |
handle = open(name) | |
emails = list() | |
count = dict() | |
for line in handle: | |
if not line.startswith("From ") : continue | |
words = line.split() | |
emails.append (words[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fname = input("Enter file name:") | |
handler = open(fname,'r') | |
file = handler.read() | |
words = file.split() | |
req = input("Enter the word you want to find in the file:") | |
ans = words.count(req) | |
print (req," occurs ",ans, " times.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = raw_input("Enter file:") | |
if len(name) < 1 : name = "mbox-short.txt" | |
handle = open(name) | |
hour = list() | |
count = dict() | |
for line in handle: | |
if not line.startswith("From ") : continue | |
time = line.split()[5] | |
hour.append(time.split(":")[0]) | |
for key in hour: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<nav class="navbar navbar-default navbar-fixed-top"> | |
<div class="container"> | |
<div class="navbar-header"> | |
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
<a class="navbar-brand" href="#myPage">Mani Chabba</a> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re #using regular expressions | |
print sum(map(int, re.findall('[0-9]+',open('RegexSum289081.txt').read()))) | |
#Outline-read the file, look for integers using the re.findall(),converting the extracted strings to integers and summing up the integers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
mysock.connect(('www.pythonlearn.com', 80)) | |
mysock.send('GET http://www.pythonlearn.com/code/intro-short.txt HTTP/1.0\n\n') | |
while True: | |
data = mysock.recv(512) | |
if ( len(data) < 1 ) : | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
from BeautifulSoup import * | |
url = raw_input("Enter the URL:") | |
html = urllib.urlopen(url).read() | |
soup = BeautifulSoup(html) | |
tags=soup('span') | |
x = list() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""The program will use urllib to read the HTML from the data files below, | |
extract the href= vaues from the anchor tags, | |
scan for a tag that is in a particular position from the top and follow that link, | |
repeat the process a number of times, and report the last name you find.""" | |
import re | |
import urllib | |
from BeautifulSoup import * | |
url = raw_input('Enter URL:') |
OlderNewer