どのようにしてこのファイルを元のファイルを再現するために単語とリストのリストに圧縮するのですか?次に、元のファイルの圧縮されたファイルを取り出し、句読点や大文字を含む完全なテキストを再作成します。これをどのように把握するのですか?
startsentence = input("Please enter a sentence: ")
sentence = (startsentence)
a = startsentence.split(" ")
dict = dict()
number = 1
positions = []
for j in a:
if j not in dict:
dict[j] = str(number)
number = number + 1
positions.append(dict[j])
print (positions)
print(positions)
f = open("postions.txt", "w")
f.write(str(positions) + "\n" )
f.close()
print(sentence)
f = open("words.txt", "w")
f.write(str(startsentence) + "\n" )
f.close()
質問がありますか? – DeepSpace
申し訳ありませんが、私は間違って言いました、1秒。 –
標準のPythonの 'dict'型を隠す変数名として' dict'を使用しないでください。 – AChampion