Так как ID постоянно менялся, я решил пойти другим путем. Я использовал следующий код:
Pattern p = Pattern.compile("\"source\":\"(.*?)\",\"width");
Matcher m = p.matcher(responseSB);
if (m.find()) {
url = m.group(1);
}
p = Pattern.compile("\"title\":(.*?)\",\"thumbnail");
m = p.matcher(responseSB);
if (m.find()) {
description = m.group(1);
}
Если Вы не хотите новой строки в конце оператора печати:
import sys
sys.stdout.write("text")
>>> 'Hai Hello\nGood eve\n'.replace('\n', ' ')
'Hai Hello Good eve '
Можно использовать replace
метод:
>>> a = "1\n2"
>>> print a
1
2
>>> a = a.replace("\n", " ")
>>> print a
1 2
Добавьте запятую после "печати":
print "Hai Hello",
print "Good eve",
Altho "печать" ушел в Python 3.0
Не уверен, что это то, о чем вы просите, но вы можете использовать строку в тройных кавычках:
print """Hey man
And here's a new line
you can put multiple lines inside this kind of string
without using \\n"""
напечатает:
Hey man And here's a new line you can put multiple lines inside this kind of string without using \n
В Python 2.6:
print "Hello.",
print "This is on the same line"
В Python 3.0
print("Hello", end = " ")
print("This is on the same line")