๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • Tried. Failed. Logged.
728x90

๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/ํŒŒ์ด์ฌ35

ํŒŒ์ด์ฌ - pip๊ฐ€ ์ œ๋Œ€๋กœ ์‹คํ–‰์ด ์•ˆ๋ผ์„œ ํŒจํ‚ค์ง€ ์„ค์น˜๊ฐ€ ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ(macOS, Linux) macOS ํ˜น์€ Linux์—์„œ pip ์„ค์น˜๊ฐ€ ์ œ๋Œ€๋กœ ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ๋Š” ์‰˜์ด pip์˜ ๊ฒฝ๋กœ๋ฅผ ์ž˜๋ชป ์„ค์น˜ํ•ด์„œ ๋‹ค๋ฅธ ๊ฒฝ๋กœ๋กœ ์„ค์น˜๋˜๋Š” ์˜ค๋ฅ˜์ผ ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. $ which pip output: /usr/local/bin/pip $ cd /usr/local/bin $ sudo rm -r pip* # for each version to remove ์œ„์ฒ˜๋Ÿผ /usr/loca/bin์˜ pip๋“ค์„ ์ „๋ถ€ ์‚ญ์ œํ•ด์„œ python์˜ bin์— ์žˆ๋Š” pip์„ ๋ถˆ๋Ÿฌ์˜ค๋„๋ก ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •์„ ํ•ด์•ผ ํ•œ๋‹ค. ์•„๋ž˜์˜ ํ•œ์ค„์„ ์ž์‹ ์ด ์‚ฌ์šฉํ•˜๋Š” ์‰˜์˜ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ • ํŒŒ์ผ ๋งจ๋งˆ์ง€๋ง‰์— ์ ์–ด์ค€๋‹ค. export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.9/bin" export PATH="$PATH.. 2022. 7. 8.
ํŒŒ์ด์ฌ - ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์˜ˆ์ œ ์ฐธ๊ณ  ์œ„ํ‚ค ๋ฌธ์„œ(์ ํ”„ ํˆฌ ํŒŒ์ด์ฌ) https://wikidocs.net/book/5445 ์ ํ”„ ํˆฌ ํŒŒ์ด์ฌ - ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์˜ˆ์ œ ํŽธ > ๋ฌธ์ œ ํ’€์ด๋กœ ์•Œ์•„๋ณด๋Š” **ํŒŒ์ด์ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ**! ๋ณด๋‹ค ๋Šฅ์ˆ™ํ•˜๊ฒŒ ํŒŒ์ด์ฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ ค๋ฉด ํŒŒ์ด์ฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋Œ€ํ•ด์„œ ์ž˜ ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•œ๋‹ค. ์ด ์ฑ…์€ ํŒŒ์ด์ฌ ๊ฐœ๋ฐœ์ž๋ผ๋ฉด ... wikidocs.net https://076923.github.io/posts/Python-tkinter-1/ Python tkinter ๊ฐ•์ขŒ : ์ œ 1๊ฐ• - GUI ์ƒ์„ฑ tkinter 076923.github.io ๋” ์ž์„ธํ•˜๊ฒŒ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋ถ„์„ํ•˜๊ณ  ์‹ถ์œผ๋ฉด ์•„๋ž˜ ๋งํฌ๋กœ https://docs.python.org/ko/3/library/ ํŒŒ์ด์ฌ ํ‘œ์ค€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ — Python 3.10.5 ๋ฌธ์„œ ํŒŒ์ด์ฌ ํ‘œ์ค€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํŒŒ์ด์ฌ ์–ธ์–ด ๋ ˆํผ๋Ÿฐ์Šค ๋Š”.. 2022. 6. 28.
ํŒŒ์ด์ฌ - ํ…”๋ ˆ๊ทธ๋žจ ๋ด‡ ํŒŒ์ผ ์—…๋กœ๋“œ(๋ด‡์ด ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ) def uploader(update: Update, context: CallbackContext) -> None: try: with open(update.message.document.file_name, 'wb') as f: context.bot.get_file(update.message.document).download(out=f) update.message.reply_text( 'ํŒŒ์ผ ์—…๋กœ๋“œ ์„ฑ๊ณต.' ) except: update.message.reply_text( 'ํŒŒ์ผ ์—…๋กœ๋“œ ์‹คํŒจ.' ) updater.dispatcher.add_handler(MessageHandler(Filters.document, uploader)) ์ถœ์ฒ˜: https://stackoverflow.com/questions/622.. 2022. 6. 18.
ํŒŒ์ด์ฌ - ์ค‘๋ณต ์—†๋Š” ๊ณ ์œ ์„ฑ์ด ๋ณด์žฅ๋˜๋Š” id ๋งŒ๋“ค๊ธฐ(uuid) import uuid uuid.uuid4() #uuid4 => full random uuid # Outputs something like: UUID('0172fc9a-1dac-4414-b88d-6b9a6feb91ea') uuid๋ž€ ๊ณ ์œ ์„ฑ์ด ๋ณด์žฅ๋˜๋Š” id๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ํ‘œ์ค€ ๊ทœ์•ฝ์„ ๋งํ•œ๋‹ค. ์ถœ์ฒ˜: https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits Random string generation with upper case letters and digits How do I generate a string of size N, made of numbers and uppercase .. 2022. 6. 18.
ํŒŒ์ด์ฌ - ํ˜„์žฌ ๋ผ์ธ๋ฒˆํ˜ธ ์ถœ๋ ฅ import inspect def lineno(): """ ์ด ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•œ ๊ณณ์˜ ๋ผ์ธ๋ฒˆํ˜ธ๋ฅผ ๋ฆฌํ„ดํ•œ๋‹ค. """ return inspect.getlineno(inspect.getouterframes(inspect.currentframe())[-1][0]) print( lineno() ) try: " " except Exception as e: self.print_log( '[' + str(lineno()) + ']' '์˜ˆ์™ธ: ' + str(e), err=True) ์ถœ์ฒ˜: https://technote.luminance.kr/entry/python-%EB%94%94%EB%B2%84%EA%B7%B8-line-%EB%B2%88%ED%98%B8-%EC%B0%8D%EA%B8%B0 python ๋””๋ฒ„๊ทธ: line ๋ฒˆํ˜ธ.. 2022. 5. 25.
ํŒŒ์ด์ฌ - ini ์„ค์ • ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ import configparser def readConfigure(self): config = configparser.ConfigParser() config.read('./settings.ini', encoding='utf-8') settings = config['settings'] self.uid = settings['uid'] self.upw = settings['upw'] 2022. 5. 8.
ํŒŒ์ด์ฌ - ์Šค๋ ˆ๋“œ ์ƒ๊ด€ ์—†์ด ํ”„๋กœ๊ทธ๋žจ ์™„์ „ ์ข…๋ฃŒ import os os._exit() ์ถœ์ฒ˜: https://stackoverflow.com/questions/905189/why-does-sys-exit-not-exit-when-called-inside-a-thread-in-python Why does sys.exit() not exit when called inside a thread in Python? I am confused as to why the following code snippet would not exit when called in the thread, but would exit when called in the main thread. import sys, time from threading import Thread def testex... 2022. 5. 7.
ํŒŒ์ด์ฌ - Cloudflare ์šฐํšŒํ•˜์—ฌ ํฌ๋กค๋งํ•˜๊ธฐ pip install cloudscraper import cloudscraper scraper = cloudscraper.create_scraper() # returns a CloudScraper instance # Or: scraper = cloudscraper.CloudScraper() # CloudScraper inherits from requests.Session print scraper.get("http://somesite.com").text ๋‚˜๋ฌด์œ„ํ‚ค ๋˜ํ•œ Cloudflare๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ผ๋ฐ˜์ ์ธ ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” ํฌ๋กค๋ง์ด ํž˜๋“ค๋‹ค. ๊ทผ๋ฐ ์ด ๋ชจ๋“ˆ ์„ค์น˜ํ•˜๋ฉด ํฌ๋กค๋ง์ด ๊ฐ€๋Šฅํ•ด์ง. ์ถœ์ฒ˜: https://stackoverflow.com/questions/49087990/python-request-being.. 2022. 1. 29.
ํŒŒ์ด์ฌ - base64๋ฅผ ์ด๋ฏธ์ง€ ํŒŒ์ผ๋กœ ์ €์žฅํ•˜๊ธฐ import base64 imgdata = base64.b64decode(imgstring) filename = 'some_image.jpg' # I assume you have a way of picking unique filenames with open(filename, 'wb') as f: f.write(imgdata) # f gets closed when you exit the with statement # Now save the value of filename to your database ์ถœ์ฒ˜: https://stackoverflow.com/questions/16214190/how-to-convert-base64-string-to-image/16214280 How to convert base6.. 2021. 12. 8.
ํŒŒ์ด์ฌ - ์—ฌ๋Ÿฌ๊ฐœ์˜ ๋ฌธ์ž์—ด ๋ณ€๊ฒฝํ•˜๊ธฐ import re txt = "Hi, my phone number is 089992654231. I am 34 years old. I live in 221B Baker Street. I have 1,000,000 in my bank account." def processString3(txt): txt = re.sub('[0-9]', 'X', txt) print(txt) processString3(txt) ์ถœ์ฒ˜: https://www.delftstack.com/ko/howto/python/python-replace-multiple-characters/ Python์—์„œ ๋ฌธ์ž์—ด์˜ ์—ฌ๋Ÿฌ ๋ฌธ์ž๋ฅผ ๋ฐ”๊พธ๋Š” ๋ฐฉ๋ฒ• ์ด ๊ธฐ์‚ฌ๋Š” Python์—์„œ ๋ฌธ์ž์—ด์˜ ์—ฌ๋Ÿฌ ๋ฌธ์ž๋ฅผ ๋ฐ”๊พธ๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. www.delftstack.com 2021. 12. 8.
Flask - static ํŒŒ์ผ๋“ค ์ œ๊ณตํ•˜๊ธฐ from flask import Flask, request, send_from_directory # set the project root directory as the static folder, you can set others. app = Flask(__name__, static_url_path='') @app.route('/js/') def send_js(path): return send_from_directory('js', path) if __name__ == "__main__": app.run() ์ถœ์ฒ˜: https://stackoverflow.com/questions/20646822/how-to-serve-static-files-in-flask How to serve static files in .. 2021. 12. 8.
728x90