편집 기록

편집 기록
  • 프로필 알 수 없는 사용자님의 편집
    날짜2019.06.30

    파이썬 초보가 오픈소스 공부하다가..


    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
    

    위 코드에서 commandes에 무엇을 넣는다는건지 a{:03d}가 의미하는것과 format이 정확히 무엇인지 알려주시면 감사하겠습니다!

  • 프로필 김진명님의 편집
    날짜2019.06.29

    파이썬 초보가 오픈소스 공부하다가..


    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
    

    위 코드에서 commandes에 무엇을 넣는다는건지 'a{:03d}'가 의미하는것과 format이 정확히 무엇인지 알려주시면 감사하겠습니다!