下面的函數是否正確使用.join函數?我試圖在沒有引號和逗號的情況下組建所有O的董事會。輸出與板的輸入相同,不會刪除逗號或引號。我是Python的新手,所以我還沒有掌握使用這些內置函數的正確方法。.join函數在循環中不起作用
board = []
for x in range(5):
board.append(['O'] * 5)
def print_board(oChart):
for row in oChart:
#this line below is were the error occurs
" ".join(row)
print row
print_board(board)
運行時的輸出是:
['O','O','O','O','O']
['O','O','O','O','O']
['O','O','O','O','O']
['O','O','O','O','O']
['O','O','O','O','O']
我打算輸出接收: