【发布时间】:2013-11-07 14:52:21
【问题描述】:
最pythonic的加入列表的方式是什么,以便每个项目之间有逗号,除了最后一个使用“and”的项目?
["foo"] --> "foo"
["foo","bar"] --> "foo and bar"
["foo","bar","baz"] --> "foo, bar and baz"
["foo","bar","baz","bah"] --> "foo, bar, baz and bah"
【问题讨论】:
-
谁在乎牛津逗号?
-
本问答不使用Oxford comma。对于使用牛津逗号的问题和答案,请参阅this question。