Ich habe das folgende Programm erstellt und eine CSV-Datei importiert, die Wörter enthält, die sich auf häufige Telefonprobleme beziehen. Mein Problem ist, dass es "zerschlagen" wird, aber wegen des Kommas wird es nicht "zerschlagen" sein.CSV-Datei in Python, die nicht die genauen Ergebnisse gibt
Also meine Frage ist, wie kann ich es das Wort ohne das Komma lesen lassen und mir keine Fehler oder irgendetwas geben?
Jede mögliche Hilfe geschätzt :)
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.")
Bitte zeigen Sie Ihren eigenen Versuch, dies selbst zu tun und erklären, warum es nicht funktioniert. – martineau