string = "word 2 3 4 5 6 7"
string = ",".join(string.split())
line = line.replace("\s",",")
(i.e. \s = \t\n)
line = "1 2 3 4 5 6 7"
line = line.replace(" ","")
for i in list(line):
print i+",",
不是最好,没有用到python的长处,汗,基本达到要求