Python novice was studying open source.

Asked 2 years ago, Updated 2 years ago, 60 views

def commands_arduino(a,b):  # a: command, b: times

    # # Old - '%04d' % (42,)
    # # New - '{:04d}'.format(42)
    # # Output - 0042

    commands = "".join(a for i in range(b))

    if a == 'a': # left
        result = 'a{:03d}'.format(round((5.625 * b)))
    elif a == 'd': # right
        result = 'd{:03d}'.format(round((5.625 * b)))
    elif a == 'w':  # forward
        result = 'w{:03d}'.format(round(0.53125 * b))
    elif a == 'x':  # backward
        result = 'x{:03d}'.format(round(0.53125 * b))
    else:
        result = 'quit'

    return commands, result

What do you put in commands in the above code? I would appreciate it if you could tell me exactly what a{:03d} means and what format means!

pycharm python open-source

2022-09-22 14:39

1 Answers


2022-09-22 14:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.