我得到的main_watch_images列表中的两个项目,只是要打印的第一个。我试图在findall行之后添加[0],但是它会垂直打印每个字母。我想这是因为for循环在新行上打印所有内容,但是我无法设法将它全部打印在一行上。Python 2.7版 - 让for循环打印无新线
# Extract the first image (this is always the main image) that is in the
# "LIMITED" category
main_watch_images = findall('<img.* src="([^"]+).*LIMITED"', dennisov_html)
# Convert the URL to a full address
for images in main_watch_images:
if images.startswith('/'):
images = 'https://denissov.ru' + images
print images
注意这不是和其他问题相同的问题。我是一个绝对的初学者,无法理解其他答案中使用的技巧和操作符等。我需要一个具体的答案来解决我的问题。
这是什么'的findAll()'返回? Cound你展示一个示例输出? – Nurjan
[关于同一行的Python打印]的可能的复制(http://stackoverflow.com/questions/5598181/python-print-on-same-line) – DeepSpace
作为对重复的说,使用'打印图像的答案中的一个, '(注意',')。 – DeepSpace