I have written an integer to a text file like this:
dolyen = int(input("Enter exchange rate: "))
filedolyen = open("dolyen.txt","w")
filedolyen.write("%s" % dolyen)
filedolyen.close()
Then I have tried to copy the number from the file in another section of code:
yendol1 = open("yendol.txt","r")
print(value * yendol1,"Dollars")
filedolyen.read()
reads the whole file as a string
int(filedolyen.read())
to get back an integer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With