2022-05-16 기록

  • 한글로 된 경로가 있는 경우 파이참에 python3.x 다운로드해서 처리 하려고 해도 자동으로 인식 되지 않아서직접 입력해야 함
  • 버전업에 따라서 select or switch 형태의 내부 함수가 추가 (match 문법 생성)  python 3.10 이상
  • https://www.ciokorea.com/news/185423 
  • 공부 할줄 추가 해야 한다. 용법도 다행해지는건 당연하 상태
  • if / elif /else 를 경우 수가 많은 경우 대체로 사용한다.
  • default 값을 지정하고 사용을 권장
match command.split():
    case ["quit"]:
        print("Goodbye!")
        quit_game()
    case ["look"]:
        current_room.describe()
    case ["get", obj]:
        character.get(obj, current_room)
    case ["go", direction]:
        current_room = current_room.neighbor(direction)
        # The rest of your commands go here
    case _:
        # default --> 의식적으로 넣어주는 것이 정신건강에 이롭다.
        pass

출처 : https://peps.python.org/pep-0636/

 

PEP 636 – Structural Pattern Matching: Tutorial | peps.python.org

PEP 636 – Structural Pattern Matching: Tutorial Author Daniel F Moisset Sponsor Guido van Rossum BDFL-Delegate Discussions-To Python-Dev list Status Final Type Informational Created 12-Sep-2020 Python-Version 3.10 Post-History 22-Oct-2020, 08-Feb-2021 Re

peps.python.org

 

echat 사용시 차트를 이미지로 저장 시 옵션에 있는 기능을 사용할 수 있지만

외부 디자인에 넣으려고 할 때도 있다. 찾아보면

 

아래와 같은데 이는 조금 문제가 있다. 확장으로 이미지를 디자인식으로 올린 경우 저장이 동일하게 되지 않는다. 

 // Get canvas information
    let canvas = document.getElementsByTagName("canvas");
    if(canvas&&canvas.length>0){
        // create label
        let tempA = document.createElement("a");
        // Set download name
        tempA.download = "echarts download" +".png";
        // Set address and file type
        tempA.href = canvas[0].toDataURL("image/png");
        document.body.appendChild(tempA);
        // Trigger download event
        tempA.click();
        // Remove Tag
        tempA.remove();
     }

따라서 온전히 저장을 하기 위해서는 echat  내부 api를 사용해야 한다.  

/**
 * @param flNm			저장 파일명 확장자 포함
 * @param chartObj		차트 오브젝트명
 * @param pixelRt		저장 이미지 비율 default 1(1:1)
 * @returns
 */
function downloadURI(flNm, chartObj, pixelRt = 1) {
    var tempA = document.createElement("a");
    tempA.download = flNm ;
    //address 설정하고 파일의 타입 정하기
    tempA.href = chartObj.getDataURL({
        pixelRatio: pixelRt
    });
    document.body.appendChild(tempA);
    //클릭 다운로드 이벤트
    tempA.click();
    //태그를 제거합니다
    tempA.remove();
}

함수로 만들어 보았다.  내부 함수를 이용하면 온전히 이미지로 저장이 가능하다.

 

+ Recent posts