Ich habe alles versucht, was ich weiß, aber scheinen nicht die Lösung zu finden.XPath Entfernen von Leerzeichen in der Liste Python
import csv
import requests
from lxml import html
from itertools import izip
list_names_atp = []
page = requests.get('http://www.atpworldtour.com/en/rankings/singles')
tree = html.fromstring(page.content)
list_rank_atp = []
for i in range(0,101):
result = tree.xpath('//*[@id="rankingDetailAjaxContainer"]/table/tbody/tr[%s]/td[1]/text()'%(i))
list_rank_atp.append(result)
list_names_atp = []
for i in range(0,101):
result1 = tree.xpath('//*[@id="rankingDetailAjaxContainer"]/table/tbody/tr[%s]/td[4]/a/text()'%(i))
list_names_atp.append(result1)
list_Final =[]
for i in izip(list_rank_atp, list_names_atp):
uitkom = i
list_Final.append(uitkom)
outfile = open("./tennis.csv", "wb")
writer = csv.writer(outfile)
writer.writerow(["Rank", "Name"])
writer.writerows(list_Final)
Die CSV-Ausgabe sieht wie:
Aber ich will es so:
Sie benötigen Eingabe und Ausgabe als PNG-Bilder? – usr2564301
Nein, die Bilder sollten nur zeigen, wie ich es in csv sehen möchte – Depekker