폐쇄망 Python pip setting

 

1. 폐쇄망이 아닌곳에서 pakage 설치

 

2. 설치된 모듈을 리스트로 만든다

 

pip freeze > requirements.txt

 

 

 

3. 모듈 리스트 다운로드

 

pip download -r requirements.txt

 

 

 

 

 

4. 폐쇄망으로 파일들 이동 & 설치

 

python -m pip install --no-index --find-links="./" -r requirements.txt

python -m pip install --no-index --find-links="./" 설치모듈이름

'IT > Python' 카테고리의 다른 글

Python configparser Module  (0) 2021.04.14
Python filename pattern module  (0) 2021.01.22
CentOS7 Python3 Setup  (0) 2021.01.20
Python을 활용하여 Kakao 등록 팀원 UUID 값 가지고오기  (0) 2021.01.14
Python을 활용하여 Kakao MSG Send Me  (0) 2021.01.14

1. Python configparser  Module 이란?

.ini or .cfg  속성 저장

 

2. Python configparser  Module Setup

pip install configparser

 

3. Python configparser  Module

## main.py
import configparser

config = configparser.ConfigParser()

config.read('config.ini', encoding='utf-8')	#한글이 들어갈 경우 인코딩 값 설정

config['defaults']['username']
## HiHi
config['defaults']['username2']
## HiHi2

########################################
########################################
########################################

## config.ini

[defaults]
username = HiHi
username2 = HiHi2

Python filename pattern module

1. glob

from glob import glob

glob('*.exe')
['hihi.exe', 'bigtrue.exe']
glob('*.txt')
['hoho.txt', 'hehe.txt']

glob(r'C:\H*') 
['C:\\Hi', 'C:\\He']

2. fnmatch

import fnmatch
import os

for file in os.listdir('.'):
    if fnmatch.fnmatch(file, '*.txt'):
        print(file)

'IT > Python' 카테고리의 다른 글

폐쇄망 Python pip setting  (0) 2021.05.03
Python configparser Module  (0) 2021.04.14
CentOS7 Python3 Setup  (0) 2021.01.20
Python을 활용하여 Kakao 등록 팀원 UUID 값 가지고오기  (0) 2021.01.14
Python을 활용하여 Kakao MSG Send Me  (0) 2021.01.14

환경 : CentOS7

 

1. Python Website

www.python.org/downloads/

 

Download Python

The official home of the Python Programming Language

www.python.org

 

2. CentOS Python Setup

 

yum install python3 -y

 

 

 

Python을 활용하여 Kakao 등록 팀원 UUID 값 가지고오기

팀원 등록

Code

import json
import requests

def getFriendsList():
    header = {"Authorization": 'Bearer ' + KAKAO_TOKEN}
    url = "https://kapi.kakao.com/v1/api/talk/friends" #친구 정보 요청

    result = json.loads(requests.get(url, headers=header).text)

    friends_list = result.get("elements")
    friends_id = []

    print(requests.get(url, headers=header).text)
    print(friends_list)

    for friend in friends_list:
        friends_id.append(str(friend.get("uuid")))
        return friends_id



if __name__=='__main__':
    KAKAO_TOKEN = "액세스 토큰값"
    getFriendsList()

'IT > Python' 카테고리의 다른 글

Python filename pattern module  (0) 2021.01.22
CentOS7 Python3 Setup  (0) 2021.01.20
Python을 활용하여 Kakao MSG Send Me  (0) 2021.01.14
Python을 활용하여 Slack MSG Send  (0) 2021.01.14
Windows 스케줄러 Python Script 사용  (0) 2021.01.14

Python을 활용하여 Kakao MSG Send Me

Token 값 발급

Code

import os
import json
import requests

def sendToMeMessage(text):
    header = {"Authorization": 'Bearer ' + KAKAO_TOKEN}     ## Bearer 한칸띄기

    url = "https://kapi.kakao.com/v2/api/talk/memo/default/send" #나에게 보내기 주소

    post = {
        "object_type": "text",
        "text": text,
        "link": {
            "web_url": "https://developers.kakao.com",
            "mobile_web_url": "https://developers.kakao.com"
        },
        "button_title": "Button Title"
    }
    data = {"template_object": json.dumps(post)}
    return requests.post(url, headers=header, data=data)

text = "This is KaKao Message Test!!!!!"

KAKAO_TOKEN = "액세스 토큰값"   ##

print(sendToMeMessage(text).text)

+ Recent posts