2012-10-13 52 views

回答

4
>>> def test(): 
... print 'let\'s', 
... pass 
... print 'party' 
... 
>>> test() 
let's party 
>>> 

您例如:

# note the comma at the end 
print 'Going to %s' % href, 
try: 
    self.opener.open(self.url+href) 
    print 'OK' 
except: 
    print 'ERROR' 

打印语句的comma at the end指示不添加'\n'换行符。

我认为这个问题是python 2.x,因为print被用作一个语句。对于Python 3,你需要指定end=''打印功能调用:

# note the comma at the end 
print('Going to %s' % href, end='') 
try: 
    self.opener.open(self.url+href) 
    print(' OK') 
except: 
    print(' ERROR') 
+0

Got you!非常感谢 – Vor

+0

似乎不适用于python 3:http://pastie.org/5054695 –

+0

我从这个问题假设这不是python 3.让我包含它。 – dnozay

1

使用逗号: -

print 'Going to %s'%href, 
+0

它的作品谢谢你 – Vor