I have this:
response = urllib2.urlopen(url)
html = response.read()
begin = html.find('<title>')
end = html.find('</title>',begin)
title = html[begin+len('<title>'):end].strip()
if the url = http://www.google.com then the title have no problem as "Google",
but if the url = "http://www.britishcouncil.org/learning-english-gatewa...
hello , i am new to python , and I want to extract the data from this format
FBpp0143497 5 151 5 157 PF00339.22 Arrestin_N Domain 1 135 149 83.4 1.1e-23 1 CL0135
FBpp0143497 183 323 183 324 PF02752.15 Arrestin_C Domain 1 137 138 58.5 6e-16 1 CL0135
FBpp0131987 60 280 51 280 PF00089.19 Trypsin Domain 14 219 219 127.7 3.7e-37 1 CL0124
t...
What's the best way to store and retrieve a python dict in a database?
...
Is there an elegant, cross-platform, industry standard way of implementing substr() in C?
or is it a case of every developer reinventing the wheel?
EDIT: Added 'cross-platform'.
...
// The first example:
char text[] = "henri";
char *p;
p = text;
*(p + 1) = 'E'; // Output = hEnri
// Now If we want to remove the "e" ie hnri, we would go for?????
*(p + 1)=?????
The obvious answer is to copy the rest of the array "back" one position. But this seems... unpleasant. Surely there is some better way?
...
I have the following string:
"h3. My Title Goes Here"
I basically want to remove the first 4 characters from the string so that I just get back:
"My Title Goes Here".
The thing is I am iterating over an array of strings and not all have the h3. part in front so I can't just ditch the first 4 characters blindly.
I have checke...
Having a string of whitespaces:
string *str = new string();
str->resize(width,' ');
I'd like to
fill length chars at a position.
In C it would look like
memset(&str[pos],'#', length );
How can i achieve this with c++ string, I tried
string& assign( const string& str, size_type index, size_type len );
but this seems to truncat...
By fuzzy matching I don't mean similar strings by Levenshtein distance or something similar, but the way it's used in TextMate/Ido/Icicles: given a list of strings, find those which include all characters in the search string, but possibly with other characters between, preferring the best fit.
...
What am I doing wrong/what can I do?
import sys
import string
def remove(file):
punctuation = string.punctuation
for ch in file:
if len(ch) > 1:
print('error - ch is larger than 1 --| {0} |--'.format(ch))
if ch in punctuation:
ch = ' '
return ch
else:
retur...
I've written a fairly simple script that will take elements (in this case, <p> elements are the main concern) and type their contents out like a typewriter, one by one.
The problem is that as it types, when it reaches the edge of the container mid-word, it reflows the text and jumps to the next line (like word wrap in any text editor)...
Here is what I'm trying to accomplish. I have an object coming back from
the database with a string description. This description can be up to 1000
characters long, but we only want to display a short view of this. So I coded
up the following, but I'm having trouble in actually removing the number of
words after the regular expression ...
Is there any tool that will convert a multiline text, to a compatible multiline string for Visual Studio 2008/2005?
For example:
line1
line2
line3
line4
Should become:
"line1" & _
"line2" & _
"line3" & _
"line4"
...
I need to determine whether a string (sourceString) contains another string (queryString) and if it does, at what offset.
I'm guessing that NSScanner might do the trick but I don't fully understand the documentation.
Let's say sourceString = @"What's the weather in London today?"
If I set queryString to equal @"What's the weather", I...
this is my main string
"action","employee_id","name"
"absent","pritesh",2010/09/15 00:00:00
so after name coolumn its goes to new line but here i append to list a new line character is added and make it like this way
data_list*** ['"action","employee_id","name"\n"absent","pritesh",2010/09/15 00:00:00\n']
here its append the new li...
Given I have data like the following, how can I select and group by portions of a string?
Version Users
1.1.1 1
1.1.23 3
1.1.45 1
2.1.24 3
2.1.12 1
2.1.45 3
3.1.10 1
3.1.23 3
What I want is to sum up the users using version 1.1.x and 2.2.x and 3.3.x etc, but I'm not sure how I can group on a partial string in a selec...
hello , i have a string like this test_1.doc and i want to split this string to have 1.doc
...
How would you split a domain name that will return name and extension
...
Hi,
What of this code is faster/more efficient? :
Boolean contains = myString.IndexOf("~", StringComparision.InvariantCultureIgnoreCase)!=-1;
or
Boolean contains = myString.IndexOf('~')!=-1;
I think the second because is a single character, but using the invariant culture ignore case comparer is supposed to be fast too :P
Cheers....
Very simple question, hopefully. So, in Python you can split up strings using indices as follows:
>>> a="abcdefg"
>>> print a[2:4]
cd
but how do you do this if the indices are based on variables? E.g.
>>> j=2
>>> h=4
>>> print a[j,h]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: string indices must be i...
Hello,
I have a PHP variable that holds some HTML I wanting to be able to split the variable into two pieces, and I want the spilt to take place when a second bold <strong> or <b> is found, essentially if I have content that looks like this,
My content
This is my content. Some more bold content, that would spilt into another variab...