Previously I wrote all of my python code on a Windows 10 machine, but more recently I've been trying to move over to MacOS. Everything is working just fine, with one exception. I'm writing a program that uses the python 'input' function and when pressing ↑ on MacOS it prints '^[[a' but on Windows 10 it prints the previous input. Is there get the previous input with the up arrow on Mac?
while True:
string = input()
print(string)
On Windows hitting ↑ will print the previous input but on Mac '^[[a' will print
Use readline module to provide reading and writing of history files. More info on that in the docs
import readline
while True:
string = input()
print(string)
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