본문 바로가기

python2392

파이썬 Python Weather API 날씨 데이터를 Python 프로그램으로 가져 오려면 어떻게해야합니까? 해결 방법 OpenWeatherMap 서비스는 무료 날씨 데이터 및 예보 API를 제공합니다. suitable for any cartographic services like web and smartphones applications. Ideology is inspired by OpenStreetMap and Wikipedia that make information free and available for everybody. OpenWeatherMap provides wide range of weather data such as map with current weather, week forecast, precipitation, wind,.. 2021. 1. 26.
파이썬 How to split a column into two columns? 하나의 열이있는 데이터 프레임이 있는데 하나의 열 머리글이 ' fips'이고 다른 하나는 'row' 인 두 개의 열로 나누고 싶습니다. 내 데이터 프레임 df 는 다음과 같습니다. row 0 00000 UNITED STATES 1 01000 ALABAMA 2 01001 Autauga County, AL 3 01003 Baldwin County, AL 4 01005 Barbour County, AL 행 셀 분할 목표를 달성하기 위해 df.row.str [:] 을 사용하는 방법을 모르겠습니다. df [ 'fips'] = hello 를 사용하여 새 열을 추가하고 hello 로 채울 수 있습니다. 어떤 아이디어? fips row 0 00000 UNITED STATES 1 01000 ALABAMA 2 01001 .. 2021. 1. 26.
파이썬 Python PIL bytes to Image import PIL from PIL import Image from PIL import ImageDraw from PIL import ImageFont import urllib.request with urllib.request.urlopen('http://pastebin.ca/raw/2311595') as in_file: hex_data = in_file.read() print(hex_data) img = Image.frombuffer('RGB', (320,240), hex_data) #i have tried fromstring draw = ImageDraw.Draw(img) font = ImageFont.truetype("arial.ttf",14) draw.text((0, 220),"This is a .. 2021. 1. 26.
파이썬 목록 및 문자열에서 일치하는 단어 찾기 파이썬으로 코드를 작성 중이고 단어 목록이 긴 문자열에 있는지 확인하고 싶습니다. 나는 그것을 여러 번 반복 할 수 있다는 것을 알고 있으며 그것은 같은 것일 수 있지만 더 빠른 방법이 있는지 확인하고 싶었습니다. 내가 현재하는 일은 다음과 같습니다. all_text = 'some rather long string' if "motorcycle" in all_text or 'bike' in all_text or 'cycle' in all_text or 'dirtbike' in all_text: print 'found one of em' 하지만 내가 원하는 것은 다음과 같습니다. keyword_list = ['motorcycle', 'bike', 'cycle', 'dirtbike'] if item in ke.. 2021. 1. 26.
파이썬 How do I change the figure size with subplots? 나는 시도했다 f.figsize(15,15) 하지만 아무것도하지 않습니다. 해결 방법 이미 Figure 개체가있는 경우 다음을 사용합니다. f.set_figheight(15) f.set_figwidth(15) 그러나 .subplots () 명령을 사용하여 (표시하는 예제에서와 같이) 새 Figure를 만들면 다음을 사용할 수도 있습니다. f, axs = plt.subplots(2,2,figsize=(15,15)) 참조 페이지 https://stackoverflow.com/questions/14770735 2021. 1. 26.
파이썬 Django에서 선택 항목을 확인란으로 표시하는 방법이 있습니까? 관리자 인터페이스와 새로운 양식에는 선택을 정의 할 수있는 훌륭한 도우미가 있습니다. 다음과 같은 코드를 사용할 수 있습니다. APPROVAL_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), ('cancelled', 'Cancelled'), ) client_approved = models.CharField(choices=APPROVAL_CHOICES) 양식에 드롭 다운 상자를 만들고 사용자가 이러한 옵션 중 하나를 선택하도록합니다. 확인란을 사용하여 여러 개를 선택할 수있는 선택 항목 집합을 정의하는 방법이 있는지 궁금합니다. (사용자가 최대 개수를 선택할 수 있다고 말할 수있어 좋을 것입니다.) 아마도 구현 된 기능인 것 같습니다. 문서에서 찾을 수없는 것 같습니다. 해결 방.. 2021. 1. 26.
파이썬 How to change the color of certain words in the tkinter text widget? 나는 파이썬 셸처럼되고 싶은 프로그램을 가지고 있으며, 특정 단어를 입력 할 때 색상을 변경합니다. 도움이 필요하세요? 해결 방법 다음은 tag_configure , tag_add 및 tag_remove 메소드를 사용하는 예입니다. #!/usr/bin/env python3 import tkinter as tk from tkinter.font import Font class Pad(tk.Frame): def __init__(self, parent, *args, **kwargs): tk.Frame.__init__(self, parent, *args, **kwargs) self.toolbar = tk.Frame(self, bg="#eee") self.toolbar.pack(side="top", fill="x".. 2021. 1. 26.
파이썬 Tkinter 창이 열리는 위치를 지정하는 방법은 무엇입니까? 화면 크기에 따라 Tkinter 창에 열 위치를 어떻게 알릴 수 있습니까? 중간에 열고 싶습니다. 해결 방법 import tkinter as tk root = tk.Tk() # create a Tk root window w = 800 # width for the Tk root h = 650 # height for the Tk root # get screen width and height ws = root.winfo_screenwidth() # width of the screen hs = root.winfo_screenheight() # height of the screen # calculate x and y coordinates for the Tk root window x = (ws/2) - (w/2) .. 2021. 1. 26.
파이썬 Python에서 PATH 환경 변수 구분 기호를 얻는 방법은 무엇입니까? 실행 가능한 검색 경로에서와 같이 여러 디렉토리를 연결해야하는 경우 OS 종속 구분 문자가 있습니다. Windows의 경우 ';'이고 Linux의 경우 ':'입니다. 파이썬에서 분할 할 문자를 얻는 방법이 있습니까? 해결 방법 참조 페이지 https://stackoverflow.com/questions/1499019 2021. 1. 25.
파이썬 Python에서 Selenium WebDriver로 부분 스크린 샷을 찍는 방법은 무엇입니까? Python에 유사한 솔루션이 있습니까? 해결 방법 Selenium 외에이 예제에는 PIL Imaging 라이브러리도 필요합니다. 때로는 이것은 표준 라이브러리 중 하나로 삽입되고 때로는 그렇지 않은 경우도 있지만,없는 경우 pip install Pillow 로 설치할 수 있습니다. from selenium import webdriver from PIL import Image from io import BytesIO fox = webdriver.Firefox() fox.get('http://stackoverflow.com/') # now that we have the preliminary stuff out of the way time to get that image :D element = fox.find.. 2021. 1. 25.