试图打印希伯来语的组合,但打印其他字符python27

时间:2019-02-18 10:04:46

标签: python combinations brute-force

我尝试使用在网上找到的ocde来组合希伯来字母,但这是结果: 我无法打印希伯来语的合并权利,但我认为这是编码方面的麻烦。 使用python 2.7.15 代码:

com.fasterxml.jackson

和控制台结果:

# -*- coding: utf-8 -*-
your_list = 'אבגדהוזחטיכלמנסעפצקרשת '
complete_list = []
max_length = 2
a = []
print 'Starting find combinations for', max_length, 'letters, with the         chars"'+your_list+'"'
for current in xrange(max_length):
a = [i for i in your_list]
for y in xrange(current):
    a = [x+i for i in your_list for x in a];
complete_list = complete_list + a
for x in complete_list:
    print x.decode("utf-8")

这只是一部分

1 个答案:

答案 0 :(得分:1)

使用itertools.product

import itertools

your_list = 'אבגדהוזחטיכלמנסעפצקרשת '

for p in itertools.product(your_list, your_list):
    print(",".join(p))

输出:

א,א
א,ב
א,ג
א,ד
א,ה
א,ו
א,ז
א,ח
א,ט
א,י
...

顺便说一句,Python 2 will retire in ...