Apr-12-2019, 08:30 AM
(This post was last modified: Apr-12-2019, 08:50 AM by microphone_head.)
Quote:import time import sys animation = '|/-\\' for i in range(25): time.sleep(0.1) sys.stdout.write(f"\r{animation[i % len(animation)]}") sys.stdout.flush()
Do I need to import another library?
I've tried running this in Python 2.7.9 and Python 3.4.2 and I cant't get it to work. It reports a syntax error on the following line:
sys.stdout.write(f"\r{animation[i % len(animation)]}")FYI. I'm running the Python on a Raspberry Pi 2B+.
(Apr-11-2019, 11:24 AM)perfringo Wrote:Quote:Unless an 'r' or 'R' prefix is present, escape sequences in string and bytes literals are interpreted according to rules similar to those used by Standard C.Escape sequence\b
meaning is "ASCII Backspace (BS)". Other sequences and their meanings are available in Python documentiation (String and Byte Literals)
Hi perfringo,
I don't understand what you mean. I've had a quick read of the link you gave . I tried the following:
print("MH\rb") print("MH\Rb")and got
Output:MH
b
MH\Rb
I was toying with the idea of being able to write some chars to the Python shell before deleting it to make a progress bar. Can you give an example ?