0

I get a file not found error when trying to run this script

class Account: 

    def __init__(self, filepath):
        with open(filepath, 'r') as file:
            self.balance=int(file.read()) 


account=Account("~/Desktop/Courses/Python/account/balance.txt") 
print(account)

balance.txt exists and I am running the script from the directory.

h.pylori
  • 53
  • 5
  • 1
    See [this question](https://stackoverflow.com/q/3488603/2280890). Use [`os.path.expanduser`](https://docs.python.org/3/library/os.path.html#os.path.expanduser) – import random Sep 29 '22 at 02:20

0 Answers0