首先想的說,我一直在研究論壇上約2天,並沒有發現任何適合我。那麼,我們走吧。我廢除一個網站,我只需要按順序設置python代碼的輸出。Python,代碼爲csv。故障
這就是我它運行後得到:
1
Kidderminster Harr
1183
283
138
170
1005
731
""
208
148
236
813
877
""
+210
1727
.536
在單列..
這就是我想要的東西:我想是這樣
1, Kidderminster Harr, 1183, 283, 138, 170, 1005, 731, "", 208, 148, 236,etc...
一個CSV前一段時間,我記得加+「」每個元素將使招......現在我不知道爲什麼不工作了..
這是我到目前爲止:
import requests
from bs4 import BeautifulSoup
req = requests.get('http://www.statto.com/football/stats/england/national-league/all-time-table', headers={'User-Agent':'a-user-agent'})
soup = BeautifulSoup(req.text)
summary = soup.find("div",{"id" : "page-content"})
tables = summary.find('table')
count = 0
for row in tables.findAll('tr'):
for cell in row.findAll('td'):
data = cell.getText()
if (count < 18):
data = data + ';'
print data
count += 1
if (count==19):
print data
count = 0
任何想法將非常感激。
這就是我講的!謝啦!!我已經3天瘋了,只是我忘了把這個','打印後! – Enaggi
Python 3和/或「from __future__ import print_function」爲您提供打印函數與打印語句。這可以傳遞一個「end」參數,如end =「」來抑制換行符。但在Python 2中,這是它的工作原理。 – RobertB