2024-10-05 10:04:48 发布
网友
我尝试在python中合并两个字符串列表,比如:
['this','is','list one'] ,['and','list two','combined']
成为一张单子。在
不适合我
原代码:
for word in passwordslist: frequencyList+=[word[x:x+N] for x in xrange(len(word)-N+1)]
(尝试收集字符串passwordlist的所有N-gram)
初始化列表?在
frequencyList = [] for word in passwordslist: frequencyList += [word[x:x+N] for x in xrange(len(word)-N+1)]
你也可以将此作为一种理解:
>>> first_list = ['this', 'is', 'list one'] >>> second_list = ['and', 'list two', 'combined'] >>> first_list.extend(second_list) >>> print first_list ['this', 'is', 'list one', 'and', 'list two', 'combined']
初始化列表?在
你也可以将此作为一种理解:
^{pr2}$相关问题 更多 >
编程相关推荐