파일 파서 개발
- 파일에서 데이터를 읽어 파일명과 버전을 분리해서 반환한다.
packages.txt @ant-design-colors-7.2.1@ant-design-cssinjs-1.24.0@ant-design-cssinjs-utils-1.1.3@ant-design-fast-color-2.0.6@ant-design-icons-5.6.1@ant-design-icons-svg-4.4.2@ant-design-react-slick-1.1.2@babel-code-frame-7.27.1@babel-compat-data-7.28.4@babel-core-7.28.4@babel-generator-7.28.3@babel-helper-compilation-targets-7.27.2@babel-helper-globals-7.28.0@babel-helper-module-imports-7.27.1@babel-helper-module-transforms-7.28.3@babel-helper-string-parser-7.27.1@babel-helper-validator-identifier-7.27.1@babel-helper-validator-option-7.27.1@babel-helpers-7.28.4@babel-parser-7.28.4@babel-runtime-7.28.4@babel-template-7.27.2@babel-traverse-7.28.4@babel-types-7.28.4...
- 파이썬 파일 생성
Terminal window touch main.pymain.py def open_file():f = open('packages.txt', 'rt', encoding='UTF8')lines = f.readlines()for line in lines:line = line.strip()index = line.rindex('-')if index > -1:print(line[:index], "\t", line[index+1:len(line)])if __name__ == '__main__':open_file() - 데이터 파일을 같은 경로에 복사한다.
- 실행한다.
Terminal window python main.py - 출력을 확인한다.
@ant-design-colors 7.2.1@ant-design-cssinjs 1.24.0@ant-design-cssinjs-utils 1.1.3@ant-design-fast-color 2.0.6@ant-design-icons 5.6.1@ant-design-icons-svg 4.4.2@ant-design-react-slick 1.1.2@babel-code-frame 7.27.1@babel-compat-data 7.28.4@babel-core 7.28.4@babel-generator 7.28.3@babel-helper-compilation-targets 7.27.2@babel-helper-globals 7.28.0@babel-helper-module-imports 7.27.1@babel-helper-module-transforms 7.28.3@babel-helper-string-parser 7.27.1@babel-helper-validator-identifier 7.27.1@babel-helper-validator-option 7.27.1@babel-helpers 7.28.4@babel-parser 7.28.4@babel-runtime 7.28.4@babel-template 7.27.2@babel-traverse 7.28.4@babel-types 7.28.4...
- 필요한 경우 리다이렉트 하여 파일로 저장한다.
Terminal window python main.py > result.txt