如何按项目之一细分清单?

时间:2019-02-18 01:41:50

标签: python

如何用"."字符将此列表分为两个较小的列表?

示例:

word_list = ["I", "love", "icecream", ".", "I", "want", "to", "eat", "chip", "."]

smaller_list_1 = ["I", "love", "icecream", "."]

smaller_list_2 = ["I", "want", "to", "eat", "chip", "."]

1 个答案:

答案 0 :(得分:-1)

有一种使用字符串执行此操作的方法。 而不是列表,创建一个像这样的字符串:

python demo/python/porcupine_demo.py --keyword_file_paths resources/keyword_files/linux/blueberry_linux.ppn

然后使用split()函数:

OSError: Error relocating demo/python/../../lib/linux/x86_64/libpv_porcupine.so: __vfprintf_chk: symbol not found

您会得到的:

foo = "I love icecream. I want to eat chip."

然后,将两个列表项用空格分开:

list = foo.split(".")

您会得到的:

["I love icecream", "I want to eat chip"]