본문 바로가기

개발/기타

[python] notepad++에서 python 실행시키기

notepad++ F5를 누른후 cmd /K "$(FULL_CURRENT_PATH) <---입력


한글 인코딩 관련

#-*- coding:  utf-8*

윗줄에 삽입

한글입력앞에 u삽입

ex) print(u"한글")


cmd창에서 작업시 default로 한글인코딩 설정법


pythonxx\lib\site.py 열어서

setencoding으로 검색 해보면 

def setencoding():
    """Set the string encoding used by the Unicode implementation.  The
    default is 'ascii', but if you're willing to experiment, you can
    change this."""
    encoding = "ascii" # Default value set by _PyUnicode_Init()
    if 0:
        # Enable to support locale aware default string encodings.
        import locale
        loc = locale.getdefaultlocale()
        if loc[1]:
            encoding = loc[1]
    if 0:
        # Enable to switch off string to Unicode coercion and implicit
        # Unicode to string conversion.
        encoding = "undefined"
    if encoding != "ascii":
        # On Non-Unicode builds this will raise an AttributeError...
        sys.setdefaultencoding(encoding) # Needs Python Unicode build !

위의 함수가 나올텐데 첫 번쨰 if문 0을 1로 바꾸면

cmd창에서 작업시 default로 한글 인코딩이 반영되게 된다. (사용자 시스템 encoding을 따른다고 함)