반응형
반응형

[PYTHON] 파일 인코딩 관련

 

UTF-8

UTF-8-SIG

""" 
    인코딩 정보
"""
import os
import sys 
 
 
#작업하는 경로(위치)가 어디인지 확인
#print(os.getcwd())
prePath_in = "./Project/" 
prePath_out = "./Project/" 



#1. 기본 내용적기

# 기본 텍스트 신규 입력
file = open("test.txt", "w")
file.write("내용입력")
file.close()

# 한글깨짐 방지 ENCODING UTF-8
file = open("test.txt", "w", encoding="UTF-8")
file.write("내용입력")
file.close()

# 한글깨짐 방지2 ENCODING UTF-8
# txt는 UTF-8로도 충분한데 csv는 UTF-8로만 하면 읽을땐 다른걸로 읽을 경우 깨짐 현상 발생
file = open("test.csv", "w", encoding="UTF-8-sig")
file.write("test,test,test\n")
file.write("잘되나,안된다,오된다\n")
file.close()

# 참고
# Permission denied: 'test.csv' 가 나온다
# 파일 열고 있어서 수정할 수 없다는거다. 꺼주자.

# 추가 입력
file = open("test.txt", "a")
file.write("추가 내용입력")
file.close()


# 읽기
file = open("test.txt", "r", encoding="UTF-8")
print(file.read())
file.close()

# with 함수 : open & close 포함 
with open("test.txt", "w", encoding="UTF-8") as file:
    file.write("내용입력")
with open("test.txt", "r", encoding="UTF-8") as file:
    print(file.read())
 

 

#2. print 한거 txt 파일에 넣기

# sys.stdout 함수 사용하여 log 저장하기
f = open('test.txt','w', encoding='utf-8') # 로그 저장할 file open
sys.stdout = f
print("내용입력")
sys.stdout = sys.__stdout__   # 원래의 stdout으로 복구
f.close()                     # 로그 파일 닫기

#이렇게 해도 되긴 하는데.. 프로그램이 종료 안되면 문제가 생길듯?
sys.stdout = open('test.txt','w', encoding='utf-8')
print("내용입력")
반응형
반응형

ChatGPT: Optimizing
Language Models
for Dialogue

https://openai.com/blog/chatgpt/

 

ChatGPT: Optimizing Language Models for Dialogue

We’ve trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer followup questions, admit its mistakes, challenge incorrect premises, and reject inappropriate requests. ChatGPT is

openai.com

 

반응형
반응형

[python] psutil - Python에서 프로세스 및 시스템 모니터링을 위한 크로스 플랫폼 lib.

 

psutil(프로세스 및 시스템 유틸리티) 은 Python에서 실행 중인 프로세스  시스템 활용 (CPU, 메모리, 디스크, 네트워크, 센서) 에 대한 정보를 검색하기 위한 크로스 플랫폼 라이브러리입니다 . 주로 시스템 모니터링 , 프로파일링, 프로세스 리소스 제한  실행 중인 프로세스 관리 에 유용합니다 . ps, top, iotop, lsof, netstat, ifconfig, free 등과 같은 고전적인 UNIX 명령줄 도구에서 제공하는 많은 기능을 구현합니다 . psutil은 현재 다음 플랫폼을 지원합니다.

https://psutil.readthedocs.io/en/latest/

 

psutil documentation — psutil 5.9.5 documentation

Utility method retrieving multiple process information as a dictionary. If attrs is specified it must be a list of strings reflecting available Process class’s attribute names. Here’s a list of possible string values: 'cmdline', 'connections', 'cpu_aff

psutil.readthedocs.io

 

https://pypi.org/project/psutil/

 

psutil

Cross-platform lib for process and system monitoring in Python.

pypi.org

pip install psutil




psutil.virtual_memory()

 

반응형
반응형

개발자 로드맵 - https://roadmap.sh/frontend    react

 

Developer Roadmaps

Community driven roadmaps, articles, guides, quizzes, tips and resources for developers to learn from, identify their career paths, know what they don't know, find out the knowledge gaps, learn and improve.

roadmap.sh

반응형
반응형

 

Python Package Index (PyPI) : https://pypi.org/

 

PyPI · The Python Package Index

The Python Package Index (PyPI) is a repository of software for the Python programming language.

pypi.org

 

반응형
반응형

몇 줄의 Python 코드로 멋진 그림을 그리고 싶습니까? SketchPy가 도와드리겠습니다. 

이 글에서는 스케치파이가 무엇인지, 컴퓨터에서 파이썬으로 그림을 그리는 데 어떻게 활용할 수 있는지 알아보자.

 

https://pypi.org/project/sketchpy/

Install

    pip install sketchpy

it should probably work, If not then try the following code

    pip install turtle open-cv wheel sketchpy

Example

    from sketchpy import library as lib


    obj = lib.rdj()
    obj.draw()

 

from sketchpy import library
myObject = library.tom_holland()
myObject.draw()


from sketchpy import library
myObject = library.ironman_ascii()
myObject.draw()

https://pythonistaplanet.com/sketchpy/

 

Python SketchPy Tutorial | Pythonista Planet

Do you want to draw some cool pictures with a few lines of Python code? SketchPy is here to help. In this article, let's look…

pythonistaplanet.com

 

반응형

+ Recent posts