반응형

How to send text messages with Python for Free

https://medium.com/testingonprod/how-to-send-text-messages-with-python-for-free-a7c92816e1a4

 

How to send text messages with Python for Free

This week, I am going to be showing you how to send text messages with Python for free. It’s actually surprisingly easy to do and I thought…

medium.com

What you’ll need

For this post, I’ll be using the following:

It should be noted that if you’re using gmail, like me, you’ll need to setup and use an application password with your account. You can read more information and security warnings on that here: https://support.google.com/accounts/answer/185833?p=InvalidSecondFactor&visit_id=637700239874464736-1954441174&rd=1

import smtplib
import sys
 
CARRIERS = {
    "att": "@mms.att.net",
    "tmobile": "@tmomail.net",
    "verizon": "@vtext.com",
    "sprint": "@messaging.sprintpcs.com"
}
 
EMAIL = "EMAIL"
PASSWORD = "PASSWORD"
 
def send_message(phone_number, carrier, message):
    recipient = phone_number + CARRIERS[carrier]
    auth = (EMAIL, PASSWORD)
 
    server = smtplib.SMTP("smtp.gmail.com", 587)
    server.starttls()
    server.login(auth[0], auth[1])
 
    server.sendmail(auth[0], recipient, message)
 
 
if __name__ == "__main__":
    if len(sys.argv) < 4:
        print(f"Usage: python3 {sys.argv[0]} <PHONE_NUMBER> <CARRIER> <MESSAGE>")
        sys.exit(0)
 
    phone_number = sys.argv[1]
    carrier = sys.argv[2]
    message = sys.argv[3]
 
    send_message(phone_number, carrier, message)
반응형

'프로그래밍 > Python' 카테고리의 다른 글

[python] sudoku 만들기 - 랜덤 문제  (0) 2023.09.27
[python] sudoku 만들기  (0) 2023.09.27
[python] algorithm, 알고리즘  (0) 2023.09.20
[python] GUI 비밀번호 자동 생성기  (0) 2023.09.18
[python] pyperclip  (0) 2023.09.18
반응형

[한빛미디어] "이것이 취업을 위한 코딩 테스트다 with 파이썬" 전체 소스코드 저장소입니다
https://github.com/ndb796/python-for-coding-test

Types of Algorithm

    Searching
    Sorting
    Recursive
    Backtracking
    Greedy
    Randomized
    Divide & Conquer
    Dynamic Programing


 https://www.instagram.com/p/CxZgarwyv_2/?igshid=MjNiZGVkZTJkZQ%3D%3D 



https://www.geeksforgeeks.org/python-data-structures-and-algorithms/

반응형

'프로그래밍 > Python' 카테고리의 다른 글

[python] sudoku 만들기  (0) 2023.09.27
[python] How to send text messages with Python for Free  (0) 2023.09.26
[python] GUI 비밀번호 자동 생성기  (0) 2023.09.18
[python] pyperclip  (0) 2023.09.18
[Python] kivy  (0) 2023.09.15
반응형

#####
"""https://copyassignment.com/password-generator-in-python-gui-application/"""
#####
# importing the tkinter module
from tkinter import *

# importing the pyperclip module to use it to copy our generated 
# password to clipboard
import pyperclip

# random module will be used in generating the random password
import random

# initializing the tkinter
root = Tk()

# setting the width and height of the gui
root.geometry("400x400")    # x is small case here

# declaring a variable of string type and this variable will be 
# used to store the password generated
passstr = StringVar()

# declaring a variable of integer type which will be used to 
# store the length of the password entered by the user
passlen = IntVar()

# setting the length of the password to zero initially
passlen.set(0)


# function to generate the password
def generate():
    # storing the keys in a list which will be used to generate 
    # the password 
    pass1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
            'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 
            'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D',
            'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
            'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 
            'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', 
            '9', '0', ' ', '!', '@', '#', '$', '%', '^', '&', 
            '*', '(', ')']

    # declaring the empty string
    password = ""

    # loop to generate the random password of the length entered           
    # by the user
    for x in range(passlen.get()):
        password = password + random.choice(pass1)

    # setting the password to the entry widget
    passstr.set(password)

# function to copy the password to the clipboard
def copytoclipboard():
    random_password = passstr.get()
    pyperclip.copy(random_password)

# Creating a text label widget
Label(root, text="Password Generator Application", font="calibri 20 bold").pack()

# Creating a text label widget
Label(root, text="Enter password length").pack(pady=3)

# Creating a entry widget to take password length entered by the 
# user
Entry(root, textvariable=passlen).pack(pady=3)

# button to call the generate function
Button(root, text="Generate Password", command=generate).pack(pady=7)

# entry widget to show the generated password
Entry(root, textvariable=passstr).pack(pady=3)

# button to call the copytoclipboard function
Button(root, text="Copy to clipboard", command=copytoclipboard).pack()

# mainloop() is an infinite loop used to run the application when 
# it's in ready state 
root.mainloop()

Python의 tkinter 라이브러리를 사용하여 간단한 비밀번호 생성기 GUI 애플리케이션을 만든 것 같습니다. 이 애플리케이션을 사용하면 사용자는 비밀번호 길이를 지정한 다음 지정된 길이에 따라 무작위 비밀번호를 생성할 수 있습니다.

코드 분석은 다음과 같습니다.

  1. 필요한 모듈을 가져옵니다: GUI용 tkinter, 생성된 비밀번호를 클립보드에 복사하기 위한 pyperclip, 임의 문자 생성용 Random.
  2. tkinter 인스턴스를 초기화하고 GUI 창의 형상을 설정합니다.
  3. 생성된 비밀번호와 사용자가 입력한 비밀번호 길이를 저장하기 위해 tkinter 변수( passstr및 )를 만듭니다.passlen
  4. generate사용자가 지정한 길이에 따라 임의의 비밀번호를 생성하는 기능을 정의합니다 . 문자 목록( pass1)을 사용하여 무작위로 문자를 선택하여 암호를 만듭니다.
  5. copytoclipboardpyperclip 모듈을 사용하여 생성된 비밀번호를 클립보드에 복사하는 함수를 정의합니다 .
  6. 라벨, 입력 필드, 버튼 등의 GUI 요소를 생성하고 이를 기능과 연결합니다.
  7. 를 사용하여 기본 GUI 이벤트 루프를 시작합니다 root.mainloop(). 이는 사용자가 창을 닫을 때까지 애플리케이션을 계속 실행합니다.

이 코드를 실행하면 원하는 비밀번호 길이를 입력할 수 있는 GUI가 생성됩니다. "비밀번호 생성" 버튼을 클릭하여 임의의 비밀번호를 생성한 다음 "클립보드에 복사" 버튼을 클릭하여 비밀번호를 클립보드에 복사합니다. .

귀하의 코드는 기본 비밀번호 생성기 애플리케이션에 맞게 구조화되어 있고 기능적으로 작동하는 것으로 보입니다. 필요한 경우 오류 처리를 추가하거나 사용자 인터페이스를 개선하여 이를 더욱 향상시킬 수 있습니다.

반응형

'프로그래밍 > Python' 카테고리의 다른 글

[python] How to send text messages with Python for Free  (0) 2023.09.26
[python] algorithm, 알고리즘  (0) 2023.09.20
[python] pyperclip  (0) 2023.09.18
[Python] kivy  (0) 2023.09.15
[python] PDF to png, import fitz , PyMuPDF  (0) 2023.09.15
반응형

pyperclip 1.8.2

 

>> pip install pyperclip

 

 

A cross-platform clipboard module for Python. (Only handles plain text for now.)

 

https://pypi.org/project/pyperclip/

 

pyperclip

A cross-platform clipboard module for Python. (Only handles plain text for now.)

pypi.org

>>> import pyperclip
>>> pyperclip.copy('The text to be copied to the clipboard.')
>>> pyperclip.paste()
'The text to be copied to the clipboard.'

 

반응형
반응형

크로스 플랫폼 사용자 인터페이스의 신속한 개발을 위한 오픈 소스 파이썬 라이브러리다.

키비 응용 프로그램을 사용하면 리눅스, 윈도우에 사용하는 GUI 프로그램뿐 아니라 안드로이드, IOS 용도로 개발할 수 있다.

 

https://kivy.org/

 

Kivy: Cross-platform Python Framework for NUI

Open source Python framework for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.

kivy.org

https://kivy.org/doc/stable/gettingstarted/intro.html

 

Introduction — Kivy 2.2.1 documentation

Introduction Start Developing Kivy Apps Right Away! Creating Kivy apps is fun and rewarding. This guide should be the perfect starting point to get you on the right track for app development. You will require a basic knowledge of Python to follow this intr

kivy.org

https://wikidocs.net/book/8263

 

kivy 한글 공식페이지

문의: mr.everything.kr@gmail.com

wikidocs.net

# pip install kivy


from kivy.app import App
from kivy.uix.button import Button

class YourApp(App):
    def build(self):
        return Button(text="Hello, Kivy!")

if __name__ == '__main__':
    YourApp().run()
반응형
반응형

PyMuPDF is a high performance Python library for data extraction, analysis, conversion & manipulation of PDF (and other) documents.

https://pypi.org/project/PyMuPDF/

>> pip install PyMuPDF

 

https://mupdf.com/

 

1.디렉토리 안의 pdf 파일을 읽어들여서 리스트 목록을 출력

2.파일명을 넘기면 파일명_이미지순서.png 파일을 생성. 

import fitz  # PyMuPDF

 
# 파이썬 컴파일 경로가 달라서 현재 폴더의 이미지를 호출하지 못할때 작업디렉토리를 변경한다. 
import os
from pathlib import Path
# src 상위 폴더를 실행폴더로 지정하려고 한다.
###real_path = Path(__file__).parent.parent
real_path = Path(__file__).parent
print(real_path)
#작업 디렉토리 변경
os.chdir(real_path) 

directory_base = str(real_path)+"./ONE/"  # 경로object를 문자열로 변경해서 합친다. 
 


def pdf_to_png(pdf_file, input_pdf_name, output_folder):
    # Open the PDF file
    pdf_document = fitz.open(pdf_file)
    
    for page_number in range(pdf_document.page_count):
        # Get the page
        page = pdf_document[page_number]
        
        # Convert the page to an image
        image = page.get_pixmap()
        
        # Save the image as a PNG file
        image.save(f"{output_folder}/{input_pdf_name}_{page_number + 1}.png", "png")

    # Close the PDF file
    pdf_document.close()

if __name__ == "__main__":
     
    # List all files in the directory
    file_list = [f for f in os.listdir(directory_base) if os.path.isfile(os.path.join(directory_base, f))]

    # Print the list of files
    for file in file_list:
        print(file)
        
        #input_pdf = "./TWO/"+ file_name +".pdf"  # Replace with your PDF file path
        input_pdf      = "./ONE/"+ file  # Replace with your PDF file path
        input_pdf_name = os.path.splitext(file)[0]
        print(input_pdf_name)
        output_folder  = "./ONE/data"  # Replace with your output folder
        
        pdf_to_png(input_pdf, input_pdf_name, output_folder)

 

반응형

'프로그래밍 > Python' 카테고리의 다른 글

[python] pyperclip  (0) 2023.09.18
[Python] kivy  (0) 2023.09.15
[python] PyMuPDF로 코딩 없이 PDF에서 이미지 추출  (0) 2023.09.14
[python] cowsay  (0) 2023.09.14
[PYTHON] Python tkinter 강좌  (0) 2023.08.25
반응형

PyMuPDF로 코딩 없이 PDF에서 이미지 추출

 

https://wikidocs.net/181972

 

PyMuPDF로 코딩 없이 PDF에서 이미지 추출

[PyMuPDF](https://github.com/pymupdf/PyMuPDF)의 fitz를 이용해 PDF 파일에서 이미지를 추출할 수 있다. [명령행 모듈](https://p…

wikidocs.net

# PyMuPDF로 코딩 없이 PDF에서 이미지 추출


# PyMuPDF


# pip install PyMuPDF



import fitz
doc = fitz.open(PDF_FILE_PATH)
for i, page in enumerate(doc):
    img = page.get_pixmap()
    img.save(f"./data/{i}.png")



# Command 로 바로 실행하기 
# python -m fitz extract -images input.pdf
반응형

'프로그래밍 > Python' 카테고리의 다른 글

[Python] kivy  (0) 2023.09.15
[python] PDF to png, import fitz , PyMuPDF  (0) 2023.09.15
[python] cowsay  (0) 2023.09.14
[PYTHON] Python tkinter 강좌  (0) 2023.08.25
[python] chatGPT에게 TicTacToe 만들어달라고 했다.  (0) 2023.08.21
반응형
""" cowsay 
    https://pypi.org/project/cowsay/
    
    pip install cowsay
"""

import cowsay 

cowsay.cow(" hellow, Cow")

cowsay.daemon("Hi demon")

반응형

+ Recent posts