Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私が持っているとしましょう:
hello = list(xrange(100)) print hello
結果は次のとおりです。
1, 2, 3, 4, 5, 6, 7, 8, 9, 10...
これらのスペースをすべてリストから削除する必要があるため、次のようになります。
1,2,3,4,5,6,7,8,9,10...
joinは文字列オブジェクトを取るため、これらの項目を明示的に文字列に変換する必要があります。例えば:
join
hello = ','.join(list(xrange(100))) TypeError: sequence item 0: expected string, int found
そう:
hello = xrange(100) print ''.join([str(n) for n in hello])
の必要がないことに注意してくださいlist()。
list()