次のプログラムを作成し、一般的な電話の問題に関連する単語を含むCSVファイルをインポートしました。私の問題は、 "壊れた"ものを選ぶが、カンマのために "壊れた"ものを選ぶことはないということです。PythonのCSVファイルで正確な結果が得られません
私の質問は、どのようにカンマなしで単語を読ませ、何かエラーや何も与えないようにすることですか?
すべてのヘルプは理解されるであろう:)
import csv
screen_list = {}
with open('keywords.csv') as csvfile:
readCSV = csv.reader(csvfile)
for row in readCSV:
screen_list[row[0]] = row[1]
print("Welcome to the troubleshooting program. Here we will help you solve your problems which you are having with your phone. Let's get started: ")
what_issue = input("What is the issue with your phone?: ")
what_issue = what_issue.split(' ')
results = [(solution, screen_list[solution]) for solution in what_issue if solution in screen_list]
if len(results) > 6:
print('Please only insert a maximum of 6 problems at once. ')
else:
for solution, problems in results:
print('As you mentioned the word in your sentence which is: {}, the possible outcome solution for your problem is: {}'.format(solution, problems))
exit_program = input("Type 0 and press ENTER to exit/switch off the program.")
これを自分で行い、それが機能しない理由を説明してください。 – martineau