-2
Der folgende Code wird ordnungsgemäß in IDLE ausgeführt, gibt jedoch einen Fehler in der Konsole zurück.Mein Python-Skript funktioniert in IDLE aber nicht in der Konsole
import sys, math, string, time, os
from time import *
restart0 = True
while restart0:
def addDecimal():
print(".", end="\r")
breakout0 = False
invalidcommand0 = True
while invalidcommand0:
file = open("HighScores.txt","r+")
sleep(0.5)
print("\nWelcome to VACSecureServers™\n")
start = input("Would you like to start the program? ")
if start.lower() == "yes":
print("\n1. Display high scores\n2. Add a new high score\n3. Clear all high scores\n4. Quit")
option = input()
if option == "1":
print (file.read())
if os.stat("highscores.txt").st_size==0:
print("There are no highscores currently in the system, please return and input some.")
elif option == "2":
numberAppend = int(input("How many scores would you likes to add to the program? "))
for loop in range(numberAppend):
name = input("Enter the name of the user:")
score = input("Enter a score: ")
file.write(name+","+score+","+strftime("%d/%m/%y %H:%M:%S\n"))
elif option == "3":
open("HighScores.txt", 'w').close()
print("Highscores resetting")
sleep(0.4)
addDecimal()
sleep(0.6)
addDecimal()
sleep(0.9)
addDecimal()
sleep(1.2)
print("Successfully reset!")
sleep(2)
elif option == "4":
sys.exit()
file.close()
Dies ist der Fehler, den ich bekommen:
Traceback (most recent call last):
File "E:\script.py", line 12, in <module>
print("\nWelcome to VACSecureServers™\n")
File: "C:\Python3\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2122' in position 29: character maps to <undefined>
Was könnte das Problem sein?
Was erwarten Sie zu passieren? Was läuft schief? Und kannst du den Code so anordnen, dass ich es gültig bin und ich es lesen kann? Danke – doctorlove
Ich legte es aus Ich bin gerade neu zu stackoverflow, also wusste ich nicht, dass ich ein Codebeispiel verwenden musste, um es einzufügen. – PCGamer101
Sie könnten all diesen Kauderwelsch durch eine tatsächliche Beschreibung Ihres Problems ersetzen wollen. Durch das Einrücken von 4 weißen Feldern in den Post wird die Farbgebung aktiviert. –