二手产品经理

二手产品经理

THIS IS RENO

File Operations - 48 Days - Learn Python Online for 100 Days

Record#

Catbox

  1. Learned about file operations today.
  2. Use the open() function to open files, with different parameters for different opening modes, such as read-only, binary, etc.
  3. Use the write() function to write information into files.
  4. Use the close() function to close files, operations are completed only after closing.
  5. Today's exercise is to save user input content to a file, making it neat and generous.

CODE#


print("🌟HIGH SCORE TABLE🌟")
again = "y"
while again == "y":
  initials = input("Input your initials > ")
  score =int(input("Input your score > "))
  
  f = open("scoretable.txt","a+")
  f.write(f"{initials: <5}{score}\n")
  f.close()
  
  print("ADDED")
  again=input("Add another? y/n? ")
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.