私は2つのスレッド、つまりthread1
とthread2
が必要です。 thread1
は 'C++'を入力とし、['c'、 '+'、 '+']を出力し、リストに入れます。つまり、res
です。 とthread2
は入力として 'python'をとり、['p'、 'y'、 't'、 'h'、 'o'、 'n']を出力するには、res
に入れます。処理後、resは[[''、 '+'、 '+']、['p'、 'y'、 't'、 'h'、 'o'、 'n']] [['p'、 'y'、 't'、 'h'、 'o'、 'n']、['c'、 '+'、 '+']]ロジックは次のコードのようですが、スレッドバージョンコードが必要です。データを順次処理するPythonスレッド
train_set = [
'c++',
'python',
]
def to_list(item):
return list(item)
res = list(map(to_list, train_set))
print(res) # [['c', '+', '+'], ['p', 'y', 't', 'h', 'o', 'n']]
これはpython3.6では動作しませんでしたか? –
Pythonバージョンの問題、スレッドの実行時間、私は私の投稿を編集した、それは20時間を実行し、両方のスレッドを実行するのに十分な時間を与えます。 – Dadep
@Dadep確実に 'print'文はPython 3では動作しませんので、あなたはそのバージョンではテストしていません。 –