Posts

Showing posts with the label 파이썬

파이썬 공백2개 제거

Image
​ import re t_str = '에어팟3 [애플] 2020년2월14일 출시' ; if __name__ == '__main__' : pattern = re . compile ( r '\s\s+' ) print ( t_str ) startIdx = t_str . find ( '[' ) tit = "" if startIdx > - 1 : endIdx = t_str . find ( ']' ) first_tit = t_str [ startIdx : endIdx + 1 ] last_tit = t_str . replace ( first_tit , "" ) title_nm_space = "{}{}" . format ( first_tit , last_tit ) print ( title_nm_space ) title_nm = re . sub ( pattern , ' ' , title_nm_space ) print ( title_nm ) pattern = re.compile(r'\s\s+') 정규식을 이용해 2개공백을 1개공백으로 변경.

파이썬 외부 배치파일 실행하기

Image
​ import os if __name__ == '__main__' : os . system ( r '"파일위치 및 파일명.확장자"' ) 위 소스는 파이썬으로 D:\autoPush.bat을 실행하는 명령문

우분투 파이썬 설치하기

sudo apt update sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.8