본문 바로가기

PYTHON36

[Python] binary file : write and read txt file과 거의 비슷하나, 다음의 차이를 보임. 파일 내용을 담는데 사용하는 class가 str을 주로 쓰는 txt file의 경우와 달리 bytes와 bytearray를 사용한다. bytes는 immutable이고, bytearray는 mutable인 점을 기억할 것. txt file의 경우 글자수를 반환 또는 입력받는 것과 달리, byte 수를 사용함. txt file을 읽고 쓰는 건 다음을 참고. 2023.07.04 - [Python] - [Python] Text File : read and write [Python] Text File : read and write 쓰기 open으로 얻은 file object의 메서드 write 또는 print 함수를 통해 쓰기를 수행함. 당연히 해당 fil.. 2023. 7. 4.
[Python] Text File : read and write 쓰기 open으로 얻은 file object의 메서드 write 또는 print 함수를 통해 쓰기를 수행함. 당연히 해당 file object는 wt or w 등과 같이 Text file로 쓰기 (or a or x)등으로 열려야 함. 2023.07.04 - [Python] - [Python] file : open and close [Python] file : open and close Python 에서 file을 처리하기 위해선 다른 프로그래밍 언어와 마찬가지로 file에 대한 접근이 가능한 object를 얻어와야함. 이같은 object는 file handler, file descriptor 등의 여러 이름으로 불리며, 이를 얻 ds31x.tistory.com print() 함수 print 함수의 경우,.. 2023. 7. 4.
[Python] file : open and close Python 에서 file을 처리하기 위해선 다른 프로그래밍 언어와 마찬가지로 file에 대한 접근이 가능한 object를 얻어와야함. 이같은 object는 file handler, file descriptor 등의 여러 이름으로 불리며, 이를 얻어오는 작업을 가르켜 open이라고 지칭하는게 일반적임. 때문에 file을 처리하기 위해 가장 먼저 수행되는 작업을 file을 연다(open) 라고 표현함. 파일을 연다는 것은 file을 memory로 읽어들이고, 읽어들여진 file의 content등에 접근할 수 있는 기능이 구현된 object를 얻는 것이라고 할 수 있음. 이후 해당 object가 제공하는 여러 file관련 operator를 통해 읽기, 쓰기 등등이 이루어짐. 파일을 열어서 해당 file (=.. 2023. 7. 4.
[Python] Regular Expression : 표현식 기초 및요약 Regular Expression :  정규표현식 요약 Regular Expression (re) 의 기본적인 operator는 다음과 같음.Basic operatorDescription.Any character except `\n` (newline)aThe character a itselfabThe string ab itselfx|yx or y\yEscapes a special character y, such as ^+{}$()[]|\-?.*backslash 는 escape sequence로 동작을 의미함 :즉, 뒤에 오는 문자와 결합하여 newline이나 tab등을 의미하게 됨.반대로 특수한 의미를 가지는 문자들(^+{}$()[]|\-?.*)이 backslash 뒤에 오면, 자신의 특수한 의미를 잃고.. 2023. 7. 3.
[Python] venv : Python Virtual Envrionment Python 3의 경우, standard library로 venv를 virtual environment를 위해 제공하고 있음. 이를 통해 프로젝트마다 적절한 package들을 사용할 수 있게 됨. Create a virtual environment python -m venv 환경이름 위의 명령어를 통해 환경이름이라는 subdirectory가 만들어짐. 해당 directory 밑에 virtual environment를 위한 file들이 위치하고 있음. Activate the virtual environment # linux 계열 source 환경이름/bin/activate 생성된 director의 subdirectory bin 밑에 있는 `activate script를 수행하면 만들어진 가상환경이 활성화됨.. 2023. 6. 30.
[Python] pip 사용법 다음은 pip (Pip Install Python or Installer for Python)의 사용법을 간략히 정리해둔 것임. https://dsaint31.tistory.com/entry/Python-pip-%EB%9E%80-Package-Management-System [Python] pip 란 (Package Management System) pip는 Pip Installs Python를 줄인 말로, Python에서 기본적으로 사용되는 Python package management system임. pip와 같이, 줄임말이 원래 문장에 다시 들어가 있는 경우를 recursive acronym이라고 부름. python이 많은 l dsaint31.tistory.com Installation pip는 p.. 2023. 6. 30.
반응형