Python:创建由字符串组成的列表的高效语法

标签 python string list python-2.7

我是 python 的新手,主要是想找出复制此功能的语法:strings = ["foo", "bar", "apple"] 类似strings = [foo, bar, apple] 这样我就不必在所有条目周围加上引号了。谢谢!

最佳答案

strings = "foo bar apple".split()

关于Python:创建由字符串组成的列表的高效语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7323906/

相关文章:

python - 无法转换数据框列数据类型

c++ - std::string operator + 与 stringstream 的性能

list - 为什么在 Haskell 中使用 null 函数而不是 == [] 来检查空列表?

android - 相同数据具有不同 expandableList 的多个 fragment

python - Jython(WLST)/Python 通信

在 Pandas 数据框中解析/拆分 URL 的 pythonic 方法

string - golang 中的 []string 和 ...string 有什么区别?

python - 如何反转字典项并列出按公共(public)值分组的键

python - 使用 praw 发帖时自动向 reddit 添加评论

python - 如何从Python 3中多次出现的字符串中仅删除某个字符中的一个