투케이2K

46. (python/파이썬) hex , format 사용해 10 진수 정수값을 16 진수 문자열 (hex string) 로 출력 실시 본문

Python

46. (python/파이썬) hex , format 사용해 10 진수 정수값을 16 진수 문자열 (hex string) 로 출력 실시

투케이2K 2022. 7. 25. 08:05
반응형

[개발 환경 설정]

개발 툴 : SublimeText (PyScript)

개발 언어 : python

 

[소스 코드]

<!DOCTYPE HTML>
<html lang="ko">
<head>
    <title>WebTest</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">



    <!-- [pyScript 사용 관련 CDN 설정 실시] -->
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>




    <!-- [pyScript 구문 정의 실시] -->
    <py-script>
        print("=====================================")
        print("[main start]")
        print("=====================================")


        # [hex 사용해 정수 값을 16 진수 문자열로 출력 실시]
        hex_Data = hex(255)


        # [format 함수를 사용해서 16 진수 문자열 출력 실시]
        format_Data = format(255, '#X')


        # [결과 출력 실시]
        print("hex_Data : {}".format(hex_Data))
        print("format_Data : {}".format(format_Data))
       
    </py-script>
    
</head>





<!-- [body 콘텐츠 작성] -->
<body>
</body>


</html>
 

[결과 출력]

 

 
반응형
Comments