#파이썬

뎁스_2599뎁스_2599· 1년

질문제 코드에서 무엇이 잘못되었을까요? ㅜㅜ

안녕하세요, 현재 파이썬 독학을 하고 있는 사람입니다. python으로 treemap을 만들고자 하는 문제를 풀고 있는데, 답이 자꾸 나오지 않아서 무엇이 문제인지 파악하고 싶습니다! (time out 문제도 같이 발생하고 있습니다.) 문제의 로직은 아래와 같습니다. **1단계: 정렬** 여기에는 특정 방정식이 없습니다. 데이터 포인트 목록을 값의 내림차순으로 정렬하면 됩니다. (helper function 사용) 2단계: 레이아웃 초기화 방향을 결정합니다. orientation={left edge: ​if bounding box width ≥ bounding box height top edge: otherwise​ **3단계: 행 형성** For each value of k: 1) Calculate row fraction: row fraction= sum of values of first k data points / sum of all values in the list 2) Calculate individual fractions: fraction(i) = value of data point i / sum of values of first data points 3) Calculate heights and widths: ​height(i) =row fraction × bounding box height × fraction(i) width(i) = row fraction × bounding box width × fraction(i) 4) Calculate aspect ratios: aspect ratio(i) = max(width(i), height(i)) / min(width(i), height(i)) 5) Calculate distortion: distortion = max(aspect ratios) 각 값에 대해 : 1. 순서가 지정된 처음 k개의 데이터 포인트를 가져와 해당 값을 합산합니다. 그런 다음 전체 목록에 있는 모든 값의 합으로 나눕니다. 이 분수는 이 직사각형 행이 차지해야 하는 경계 상자 영역의 분수입니다. 2. k개의 데이터 포인트 각각에 대해 해당 값을 k개의 합으로 나눕니다. 행의 값. 이는 이 데이터 포인트의 직사각형이 차지해야 하는 행 영역의 비율입니다. 행의 직사각형은 위에서 아래로(행이 경계 상자의 왼쪽 가장자리에 있는 경우) 또는 왼쪽에서 오른쪽으로(행이 위쪽 가장자리에 있는 경우) 배치됩니다. 3. 위의 계산을 통해 행에 있는 각 직사각형의 높이와 너비를 결정할 수 있습니다. 긴 변을 짧은 변으로 나누어 각 직사각형의 종횡비를 계산합니다. 종횡비는 1보다 크거나 같은 숫자입니다. 여기서 1은 직사각형이 정사각형임을 의미하고, 종횡비가 매우 높으면 직사각형이 매우 왜곡되었음을 의미합니다. 4. 이 행의 왜곡을 행에 있는 직사각형의 최대 종횡비로 정의합니다. 5. k= 1인 경우 또는 이 행에 대한 왜곡이 이전 k에 대한 왜곡보다 작거나 같은 경우, 다음으로 넘어가세요. k의 다음 값이 없는 경우 이 행은 이미 목록의 모든 데이터 포인트를 사용하고 있으므로 프로세스를 중지하고 이 k 값을 유지합니다. (왜곡이 가장 낮습니다). 반면, 이전 k에 비해 왜곡이 더 크다면, 우리는 다음 k로 넘어가지 않을 것입니다 현재 k를 유지하지도 않음. 대신 프로세스를 중지하고 이전 k 값을 선택하십시오. (왜곡이 가장 적은 것). ** 재귀함수로 풀 것 ** 제가 만들고자 하는 function은 compute_rectangles(t, bounding_rec_width=1.0, bounding_rec_height=1.0) 이며, 제가 만들어야하는 function과 제가 만든 코드는 아래와 같습니다. (parameter 변경 불가, helper function 만들어서 풀어야함) def compute_rectangles(t, bounding_rec_width=1.0, bounding_rec_height=1.0): ''' Computes the rectangles for drawing a treemap of the provided tree. Inputs: t: (Tree) a tree bounding_rec_width, bounding_rec_height: (float) the width and height of the bounding rectangle. Returns: a list of Rectangle objects. ''' rectangles = [] # Initialize the list of rectangles stack = [(t, bounding_rec_width, bounding_rec_height)] # Initialize a stack for iterative processing while stack: current_tree, current_width, current_height = stack.pop() if not current_tree.children: # Base case: if the tree is a leaf, create a rectangle and add it to the list origin = (0.0, 0.0) # Set a default origin for the leaf node rectangles.append(Rectangle(origin, (current_width, current_height), current_tree.key)) else: # Sort the children of the tree sorted_tree_list = sorted_trees(current_tree.children) # Initialize the list of rectangles for the current tree row_layout = [] # Get the next row layout and leftover rectangle for tree in sorted_tree_list: # Calculate aspect ratio for each rectangle in the row row_sum = tree.value if not row_layout else sum(child[0].value for child in row_layout) + tree.value row_fraction = row_sum / sum(child.value for child in sorted_tree_list) width = row_fraction * current_width # Calculate width for each rectangle in the row height = row_fraction * current_height aspect_ratio = max(width, height) / min(width, height) # Check if adding the current rectangle improves the aspect ratio if not row_layout or aspect_ratio <= row_layout[-1][1]: row_layout.append((tree, aspect_ratio, width, height)) else: break # Recursively call the function for the current tree's children for child, _, child_width, child_height in row_layout: stack.append((child, child_width, child_height)) return rectangles 원하는 답은 이런 형식입니다. data_rectangles = {'birds': {'Apr': <tree.Tree object at 0x7faa9edaa3d0>, 'Aug': <tree.Tree object at 0x7faa9ed06cd0>, 'Dec': <tree.Tree...ect at 0x7faa9efd3b20>, 'Dec': <tree.Tree object at 0x7faa9f064070>, 'Feb': <tree.Tree object at 0x7faa9efce940>, ...}} key = 's1' @pytest.mark.parametrize("key", TEST_KEYS) def test_compute_rectangles_flat(data_rectangles, key): expected_recs = [{'color_code': [''], 'height': 0.5, 'label': 'B40', 'width': 0.8, ...}, {'color_code': [''], 'height': 0.5, 'label': 'C40', 'width': 0.8, ...}, {'color_code': [''], 'height': 1.0, 'label': 'D20', 'width': 0.19999999999999996, ...}] 혹은 ipython3으로 실행했을 경우, In [14]: data_flat = treemap.load_trees('data/sparrows.json') In [15]: recs = treemap.compute_rectangles(data_flat['s1']) In [16]: for r in recs: ...: print(r) ...: # x, y, width, height, label 순입니다. RECTANGLE 0.0000 0.0000 0.8000 0.5000 B40 RECTANGLE 0.0000 0.5000 0.8000 0.5000 C40 RECTANGLE 0.8000 0.0000 0.2000 1.0000 D20 In [17]: recs = treemap.compute_rectangles(data_flat['s2']) In [18]: for r in recs: ...: print(r) ...: RECTANGLE 0.0000 0.0000 0.6000 0.5000 Six (a) RECTANGLE 0.0000 0.5000 0.6000 0.5000 Six (b) RECTANGLE 0.6000 0.0000 0.4000 0.3750 Three RECTANGLE 0.6000 0.3750 0.4000 0.2500 Two RECTANGLE 0.6000 0.6250 0.2667 0.1875 One (a) RECTANGLE 0.6000 0.8125 0.2667 0.1875 One (b) RECTANGLE 0.8667 0.6250 0.1333 0.3750 One (c) In [19]: recs = treemap.compute_rectangles(data_flat['s3']) In [20]: for r in recs: ...: print(r) ...: RECTANGLE 0.0000 0.0000 0.5000 0.5000 6 RECTANGLE 0.0000 0.5000 0.5000 0.5000 6 RECTANGLE 0.5000 0.0000 0.5000 0.3333 4 RECTANGLE 0.5000 0.3333 0.5000 0.2500 3 RECTANGLE 0.5000 0.5833 0.4000 0.2083 2x RECTANGLE 0.5000 0.7917 0.4000 0.2083 2y RECTANGLE 0.9000 0.5833 0.1000 0.4167 1 # data_flat['s2']는 트리입니다. 그리고 helper functions(sorted_trees(tree_list), compute_row(bounding_rec, row_data, total_sum))과 class Rectangle는 아래와 같습니다. class Rectangle: ''' Simple class for representing rectangles. Attributes: x, y: (float) coordinates of rectangle's origin width, height: (float) the rectangle's width and height label: (str) text label for the rectangle color_code: (tuple) tuple for determining what color the rectangle should be ''' def __init__(self, origin, size, label="", color_code=("",)): ''' Constructs a new Rectangle. Inputs: origin: (pair of float) x and y coordinates of the rectangle's origin size: (pair of float) the width and height of the rectangle ''' # Validate parameters validate_tuple_param(origin, "origin") validate_tuple_param(origin, "size") assert label is not None, "Rectangle label can't be None" assert isinstance(label, str), "Rectangle label must be a string" assert color_code is not None, "Rectangle color_code can't be None" assert isinstance(color_code, tuple), \ "Rectangle color_code must be a tuple" self.x, self.y = origin self.width, self.height = size self.label = label self.color_code = color_code def __str__(self): format_string = "RECTANGLE {:.4f} {:.4f} {:.4f} {:.4f} {}" return format_string.format(self.x, self.y, self.width, self.height, self.label) def __repr__(self): return str(self) def sorted_trees(tree_list): ''' Sort a list of Tree instances by the value of their roots in descending order. Ties are broken by the key of the root, in (forward) alphabetical order. Returns a new sorted list without modifying the input list. Inputs: tree_list: list of Tree instances, each with an integer value. Returns: list of Tree instances, sorted. ''' return sorted(tree_list, key=lambda t: (-t.value, t.key)) def compute_row(bounding_rec, row_data, total_sum): ''' Lay out the given data points as rectangles in one row of a treemap. The row will be against the left or top edge of the bounding rectangle, depending on whether the rectangle is at least as wide as it is tall. Inputs: bounding_rec: (Rectangle) the bounding rectangle row_data: (list of Tree) the list of data points that should be included in this row. total_sum: (integer) the total value of all the rectangles that will eventually fill the bounding rectangle (not just those in this row). Returns: a tuple (row_layout, leftover_rec), where row_layout: list of pairs (rec, t), where rec is a Rectangle, and t is the Tree that Rectangle corresponds to, and leftover_rec: a Rectangle representing the leftover space in the bounding rectangle that was not used by this row. ''' if bounding_rec.width >= bounding_rec.height: return __compute_row_wide(bounding_rec, row_data, total_sum) else: row_layout_t, leftover_rec_t = __compute_row_wide( __transpose_rectangle(bounding_rec), row_data, total_sum) row_layout = [(__transpose_rectangle(rec), tr) for rec, tr in row_layout_t] leftover_rec = __transpose_rectangle(leftover_rec_t) return row_layout, leftover_rec def __transpose_rectangle(rec): ''' Returns a new rectangle that is the transpose of the input: The x and y attributes are switched, as are width and height. The label and color_code attributes are preserved. Input: rec: (Rectangle) Returns: (Rectangle) transpose of rec. ''' return Rectangle((rec.y, rec.x), (rec.height, rec.width), rec.label, rec.color_code) def __compute_row_wide(bounding_rec, row_data, total_sum): ''' Helper function for compute_row. Serves the same purpose as compute_row, but only when the bounding rectangle is at least as wide as it is tall. Inputs: Same as compute_row, except that bounding_rec must have a width greater than or equal to its height. Returns: Same as compute_row. ''' assert bounding_rec.width >= bounding_rec.height row_sum = sum(t.value for t in row_data) row_width = bounding_rec.width * row_sum / total_sum row_layout = [] y = bounding_rec.y for t in row_data: height = bounding_rec.height * t.value / row_sum rec = Rectangle((bounding_rec.x, y), (row_width, height)) if rec.width > 0 and rec.height > 0: row_layout.append((rec, t)) y += height leftover = Rectangle((bounding_rec.x + row_width, bounding_rec.y), (bounding_rec.width - row_width, bounding_rec.height)) return row_layout, leftover
267
5
1
1
피토니
피토니·2023-11-15
문제의 로직을 분석하면, 트리 구조에서 데이터를 가져와 이를 시각적으로 나타내는 데에 초점이 맞추어져 있는 것 같습니다. 특히, 각 단계별로 정렬, 레이아웃 초기화, 행 형성 등의 작업을 거쳐 최종적으로 트리맵을 생성하고 있습니다. 올려주신 코드에서 아래 내용들을 확인할 필요가 있을 것 같습니다. 레이아웃 계산: 트리의 각 노드에 대한 렉탱글의 크기와 ...
뎁스_2599뎁스_2599· 1년

질문도와주세요.

안녕하세요, 혼자 파이썬을 공부하고 있는 사람입니다. 현재 class 만들고 function 만드는 연습 문제를 풀고 있는데, 한 부분에서 막혀서 질문드립니다. 투표 프로그램을 파이썬으로 만들고자 하는데, booth의 개수와 impatience_thresholdf를 조건으로 사용하고자 합니다. booth가 하나일 때는 코드가 잘 돌아갑니다. 다만 booth가 2개 이상이고, 투표를 하러 온 사람이 직전 사람의 departure time보다 늦게 왔지만 직전보다 그 전사람의 departure time이 투표를 하러 온 사람의 도착 시간보다 빨리 끝나 해당 booth가 비어있을 경우, 투표를 하러 온 사람이 도착한 바로 그 시점에 투표를 가능하도록 만들고 싶은데, 이부분에서 계속 막힙니다. ㅜㅜㅜ 아래는 결과물인데(booth 개수: 2, impatient_threshold: 1000), 굵은 글씨로 표시한 voter의 경우 start time이 18.98 이여야 합니다. ㅜㅜ 제 예상은 booth 개수에 대한 조건문이 제대로 작동을 안하는 것 같은데 혹시 아니라면 어떤 부분이 추가/수정 되어야하는지 말씀주시면 감사하겠습니다. Arrival Voting Is Start Departure Has Time Duration Impatient Time Time Voted 13.38 4.37 F 13.38 17.75 T 15.58 0.12 F 17.75 17.86 T 17.92 4.15 F 17.92 22.07 T 18.98 11.31 T 22.07 33.38 T 26.54 5.51 F 33.38 38.89 T 29.31 0.71 F 38.89 39.60 T 43.15 5.38 F 43.15 48.54 T 44.97 4.09 T 48.54 52.62 T 49.22 9.52 F 52.62 62.15 T 49.90 18.05 F 62.15 80.19 T 모법 답안: *Arrival Voting Is Start Departure Has Time Duration Impatient Time Time Voted 13.38 4.37 F 13.38 17.75 T 15.58 0.12 F 15.58 15.70 T 17.92 4.15 F 17.92 22.07 T 18.98 11.31 T 18.98 30.29 T 26.54 5.51 F 26.54 32.05 T 29.31 0.71 F 30.29 31.00 T 43.15 5.38 F 43.15 48.54 T 44.97 4.09 T 44.97 49.06 T 49.22 9.52 F 49.22 58.74 T 49.90 18.05 F 49.90 67.94 T helper class와 function은 아래와 같고, 제가 만들고자 하는 function은 simulate function 입니다. 제 simulate function에서 어떤 부분이 수정이 되어야하는지 말씀주시면 감사하겠습니다. (helper class: VotingBooths 클래스는 수정이 불가능한 조건입니다.) class Voter: """ Class for represents a voter in a precinct. Attributes ---------- None Methods ------- __init__(arrival_time, voting_duration, is_impatient): Initializes a Voter instance with the provided attributes. """ def __init__(self, arrival_time, voting_duration, is_impatient): """ Initialize a Voter instance. Args: arrival_time (float): The time at which the voter arrives at the precinct. voting_duration (float): The time it takes for the voter to complete the voting process. is_impatient (bool): A flag indicating whether the voter is impatient. """ self.arrival_time = arrival_time self.voting_duration = voting_duration self.is_impatient = is_impatient self.start_time = None self.departure_time = None self.has_voted = False def set_start_time(self, start_time): self.start_time = start_time def set_departure_time(self, departure_time): self.departure_time = departure_time def set_has_voted(self): self.has_voted = True class VotingBooths: """ Class for representing a bank of voting booths. Attributes ---------- None Methods ------- is_booth_available(): boolean is there at least one unoccupied booth is_some_booth_occupied(): boolean is there at least one occupied booth enter_booth(v): add a voter to a booth. requires a booth to be available. time_next_free(): float when will a booth be free next (only called when all the booths are occupied) exit_booth(): remove the next voter to depart from the booths and return the voter and their departure_time. """ def __init__(self, num_booths): """ Initialize the voting booths. Args: num_booths: (int) the number of voting booths in the bank """ self._num_booths = num_booths self._q = queue.PriorityQueue() def is_booth_available(self): """Is at least one booth open""" return self._q.qsize() < self._num_booths def is_some_booth_occupied(self): """Is at least one booth occupied""" return self._q.qsize() > 0 def enter_booth(self, v): """ Add voter v to an open booth Args: v: (Voter) the voter to add to the booth. Requirements: there must be an open booth. """ assert self.is_booth_available(), "All booths in use" assert v.start_time, "Voter's start time must be set." dt = v.start_time + v.voting_duration self._q.put((dt, v)) def time_next_free(self): """ When will the next voter leave? Returns: next departure time Requirements: there must be at least one occupied booth. """ assert self.is_some_booth_occupied(), "No booths in use" # PriorityQueue does not have a peek method. # So, do a get followed by a put. (dt, v) = self._q.get() self._q.put((dt, v)) return dt def exit_booth(self): """ Remove voter with lowest departure time. Returns: the voter and the voter's departure time Requirements: there must be at least one occupied booth. """ assert self.is_some_booth_occupied(), "No booths in use" (dt, v) = self._q.get() return v, dtclass Voter: """ Class for represents a voter in a precinct. Attributes ---------- None Methods ------- __init__(arrival_time, voting_duration, is_impatient): Initializes a Voter instance with the provided attributes. """ def __init__(self, arrival_time, voting_duration, is_impatient): """ Initialize a Voter instance. Args: arrival_time (float): The time at which the voter arrives at the precinct. voting_duration (float): The time it takes for the voter to complete the voting process. is_impatient (bool): A flag indicating whether the voter is impatient. """ self.arrival_time = arrival_time self.voting_duration = voting_duration self.is_impatient = is_impatient self.start_time = None self.departure_time = None self.has_voted = False def set_start_time(self, start_time): self.start_time = start_time def set_departure_time(self, departure_time): self.departure_time = departure_time def set_has_voted(self): self.has_voted = True random.seed(seed) voters = [] current_time = 0 start_time = 0 # Initialize start_time for i in range(self.num_voters): gap, duration, impatience = util.gen_voter_parameters(self.arrival_rate, self.voting_duration_rate, self.impatience_prob) arrival_time = current_time + gap if arrival_time > self.hours_open * 60: # Discard late voters and stop generating. break voter = Voter(arrival_time, duration, impatience) voters.append(voter) current_time = arrival_time # Update start_time for the next voter start_time += duration return voters def simulate(self, seed, voting_booths, impatience_threshold): """ Simulate election day for the precinct using the specified seed, voting_booths, and impatience threshold. Args: seed: (int) the seed for the random number generator voting_booths: (VotingBooths) the voting booths assigned to the precinct for the day impatience_threshold: (int) the number of minutes an impatient voter is willing to wait (inclusive) Returns: (list of Voter) the list of Voters """ voters = self.__generate_voters__(seed) voters.sort(key=lambda x: x.arrival_time) # Sort the voters by arrival time for i, voter in enumerate(voters): prev_voter = voters[i - 1] if i > 0 else None if i == 0: start_time = voter.arrival_time else: if prev_voter.departure_time is not None and voting_booths.is_booth_available(): start_time = max(prev_voter.departure_time, voter.arrival_time) elif prev_voter.departure_time is not None and voter.arrival_time > prev_voter.departure_time: start_time = voter.arrival_time # Use voter's arrival time if voting_booths.is_some_booth_occupied(): start_time = min(voter.arrival_time, voting_booths.time_next_free()) else: start_time = voter.arrival_time if voter.is_impatient and (start_time - voter.arrival_time) > impatience_threshold * 3: # Voter leaves without voting start_time = None # Set "Start Time" to None departure_time = None # Set "Departure Time" to None else: departure_time = start_time + voter.voting_duration voter.set_start_time(start_time) if not voter.has_voted: if start_time is not None: voting_booths.enter_booth(voter) voter.set_departure_time(departure_time) voter.set_has_voted() while voting_booths.is_some_booth_occupied(): voter, departure_time = voting_booths.exit_booth() voter.set_has_voted() voter.set_departure_time(departure_time) return voters
212
2
1
0
피토니
피토니·2023-11-08
코드를 분석해보면, simulate 함수에서 투표 부스에 접근하고 투표하는 로직에 문제가 있는 것 같습니다. 코드를 단계별로 해석하고 어떻게 수정할 수 있는지 살펴보겠습니다. 우선, simulate 함수의 로직을 단순화하기 위해 각 단계를 주석과 함께 설명하겠습니다 voters 리스트를 시간 순으로 정렬합니다.각 투표자에 대해서:1. 첫 번째 투표자면, 그...
wariwariwariwari· 4년

질문파이썬 csv파일 불러 온 뒤 비교하기 질문있습니다.

import csv history_file = open('numsonly.csv','r') history_nums = csv.reader(history_file) for line in history_nums: print(line) history_file.close() (13,23,26,31 5,7,13,20 27,36,37,41 3,13,16,23 7,11,16,21) 이렇게 각 줄에 4개의 숫자가 있는 csv파일을 불러 온 뒤, a=[[7,11,16,31], [5,7,13,20], [4,6,13,20], [3,13,16,23], [5,7,60,61]] 해당 a와 csv파일을 비교한 뒤에  1. 완전히 똑같은 경우 리스트에서 제거. => 결과값 : a=[[7,11,16,31], [4,6,13,20], [5,7,60,61]]   2. csv파일의 각 라인과 a의 전체를 비교 후 csv의 1개의 라인 4개의 숫자 중 3개 이상의 수가 a에 포함되는 경우 제거.  => 결과값 : a=[[5,7,60,61]]   다음을 어떻게 해결해야할까요? 어렵네요. 
1.6K
0
wariwariwariwari· 4년

질문파이썬 연속하는 수 찾는 방법이 뭘까요??

a=[[1,2,3,4,5],[10,11,12,14,18],[7,9,20,21,23],[23,24,27,29,60]] 이렇게 2차원 리스트가 있습니다.  이 중에서 연속하는 수가 3개 이상일 경우(1,2,3 / 7,8,9...) 리스트에서 제거한다.  라고 했을 때.  for문과 if문으로 해결 가능한가요??    
1.1K
0
미숫게이너미숫게이너· 4년

질문백엔드 개발자(spring)를 희망하는 학생입니다..코테를 무슨언어로 준비할지 모르겠네요..

안녕하세요 저는 스프링으로 백엔드 개발자가 되고 싶은 학생입니다.  제가 요즘 백엔드 공부랑 같이 코테준비도 할려는데 이게 무슨 언어로 해야할지 잘모르겠네요.. 어떤 사람들은 스프링으로 할니까 자바로 진득하게 코테준비하는게 좋다고 말하고 어떤사람들은 그래도 코테 준비는 파이썬으로 하는게 좋다고 하네요... 누구 말을 들어야 할지 모르겠어요.. 파이썬이랑 자바실력은 둘다 고만고만한 수준입니다. 개인적으로는 파이썬으로 코테준비하는게 더편한데..   제가 생각하는 자바의 장점은 자바에 조금더 익숙해질수있다는 것이고 파이썬의 장점은 자바에 비해 빠르고 간편하게 코테 준비를 할수있음 여러분은 어떻게 생각하시나요?   요약하자면 1. 백엔드 개발자(spring)가 되고 싶음 2. 코테준비도중 무슨언어를 해야 좋을지 모르겠음. 각 언어의 장단점이 있다고 생각. 자바 - 자바에 대해 조금더 익숙해질수있음, 한가지 언어만 진득하게 해도 부족함. 파이썬 - 코테를 조금더 쉽고 간단하게 직관적으로 준비할수있음.  
2.7K
1
0
sonaki84
sonaki84·2021-09-17
저라면 본인이 빠르고 익숙하게 준비할 수 있는 것을 추천하겠습니다. 파이썬에 익숙하다면 파이썬으로 코테 준비를 하시면 될 것 같습니다. 그렇게해서 코테에 익숙해지신 후에 자바쪽을 보시면 좀 더 수월하게 볼 수 있기 때문에 효율적일 것 같습니다.
PaulPaul· 4년

질문Automation 프로그램 python/java?

안녕하세요, 제가 personal project 로 쇼핑 봇을 만들려고 그러는데, python 하고 java 중에 automation 만들기 뭐가 좋으나요? 두언어다 초보자 급입니다... Youtube 에서 찾아봐서 Java Selenium 에서 ChromeDriver 로 한번 automation program 만들어서 로그인 하려다가 봇 인증  걸려서 포기한적 이 있습니다. 혹시 다른 방법으로 automation program 을 만들수 있나요? 이런 비슷한 Web Automation program 만드는법 아시는 분있으시면 조언 부탁드립니다!! 감사합니다!    
1.2K
0
Blue07Eden26Blue07Eden26· 4년

질문bs4 라이브러리 설치 오류

bs4 설치 할 때 터미널에 pip install beautifulsoup4 라고  입력했는데 다음과 같은 문구가 뜨네요   Requirement already satisfied: beautifulsoup4 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (4.9.3) Requirement already satisfied: soupsieve>1.2 in c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from beautifulsoup4) (2.2.1) WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617> distutils: C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\UNKNOWN sysconfig: C:\Users\USER\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include         WARNING: Additional context: user = True home = None root = None prefix = None   코딩 시작한지 한 달도 안 되어서 뭐가 뭔지도 모르겠고,. 도와주시면 정말 감사하겠습니다. 링크 걸린 깃헙 들어가도 뭐가 뭔지 용어조차 몰라 헤메이고 있습니다ㅜ 참고로 파이썬은 업데이트 해봤고 cmd, vs code 터미널에서도 같은 문제가 뜹니다. 컴퓨터 문제인가요? 아니면 해결 방법이 있을까요
2.3K
4
0
피토니
피토니·2021-05-06
메시지는 이미 beautifulsoup4가 설치되어있다는 메시지라서 오류는 아닌 것 같습니다. 설치는 정상적으로 된 것 같으니 코드를 실행해보시고 오류가 발생하시면 다시 질문 올려주시면 확인해보겠습니다.  
슈나슈나· 4년

질문파이썬에 엔터 키를 어떤 문자로 넣어야 돼나요??

if(name==\n):         name=input("(검색모드)이름을 입력하시오:") 앞에 코드들이 있고 만약에 이전 문장에서 엔터를 치면 다른 문장으로 넘어가는 것을 하고 싶은데 이때 \n자리에 무엇을 넣어야 되는지 모르겠어요ㅜㅜ
11.3K
1
1
0
피토니
피토니·2021-04-20
아마도 터미널에서 엔터키를 입력할 때를 말씀하시는 것 같습니다. 터미널에서 입력을 빠져나오는 방법은 엔터키 밖에 없으므로 공백으로 체크하시면 됩니다. text = input("텍스트를 입력해주세요: ") if text == "": # 공백으로 체크 print("엔터키를 눌렀습니다." + text) else: print(text + " ...
머선129머선129· 4년

질문python3 pip install에 있어서 문제가 발생했습니다 (Deep Voice 관련)

딥보이스 개발을 해보려고 하는데요. 처음부터 막막하네요... http://melonicedlatte.com/machinelearning/2018/07/02/215933.html 해당 링크에서 참고하며 했는데 pip3 install -r requirements.txt 잘 다운로드 하다가 갑자기 에러가 났는데 구글링 해봐도 해답이 안보여서. 질문을올리게 됐습니다. 에러 내용이 안보일수도 있어서 직접 올려드리겠습니다. ERROR: Command errored out with exit status 1:      command: &#39;c:\users\dev\miniconda3\envs\sjg\python.exe&#39; -c &#39;import sys, setuptools, tokenize; sys.argv[0] = &#39;"&#39;"&#39;C:\\Users\\dev\\AppData\\Local\\Temp\\pip-install-8xdw8her\\markupsafe_6456daab560749f5bb5aa328c4737374\\setup.py&#39;"&#39;"&#39;; __file__=&#39;"&#39;"&#39;C:\\Users\\dev\\AppData\\Local\\Temp\\pip-install-8xdw8her\\markupsafe_6456daab560749f5bb5aa328c4737374\\setup.py&#39;"&#39;"&#39;;f=getattr(tokenize, &#39;"&#39;"&#39;open&#39;"&#39;"&#39;, open)(__file__);code=f.read().replace(&#39;"&#39;"&#39;\r\n&#39;"&#39;"&#39;, &#39;"&#39;"&#39;\n&#39;"&#39;"&#39;);f.close();exec(compile(code, __file__, &#39;"&#39;"&#39;exec&#39;"&#39;"&#39;))&#39; egg_info --egg-base &#39;C:\Users\dev\AppData\Local\Temp\pip-pip-egg-info-vh5i47z8&#39;          cwd: C:\Users\dev\AppData\Local\Temp\pip-install-8xdw8her\markupsafe_6456daab560749f5bb5aa328c4737374\     Complete output (5 lines):     Traceback (most recent call last):       File "", line 1, in       File "C:\Users\dev\AppData\Local\Temp\pip-install-8xdw8her\markupsafe_6456daab560749f5bb5aa328c4737374\setup.py", line 6, in         from setuptools import setup, Extension, Feature     ImportError: cannot import name &#39;Feature&#39;     ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.   txt 파일에는  appnope==0.1.0 audioread==2.1.5 beautifulsoup4==4.6.0 bleach==1.5.0 bs4==0.0.1 cachetools==2.0.1 certifi==2017.7.27.1 chardet==3.0.4 click==6.7 cycler==0.10.0 decorator==4.1.2 dill==0.2.7.1 ffprobe==0.5 Flask==0.12.2 Flask-Cors==3.0.3 future==0.16.0 gapic-google-cloud-datastore-v1==0.15.3 gapic-google-cloud-error-reporting-v1beta1==0.15.3 gapic-google-cloud-logging-v2==0.91.3 gapic-google-cloud-pubsub-v1==0.15.4 gapic-google-cloud-spanner-admin-database-v1==0.15.3 gapic-google-cloud-spanner-admin-instance-v1==0.15.3 gapic-google-cloud-spanner-v1==0.15.3 google-auth==1.1.1 google-cloud==0.27.0 google-cloud-bigquery==0.26.0 google-cloud-bigtable==0.26.0 google-cloud-core==0.26.0 google-cloud-datastore==1.2.0 google-cloud-dns==0.26.0 google-cloud-error-reporting==0.26.0 google-cloud-language==0.27.0 google-cloud-logging==1.2.0 google-cloud-monitoring==0.26.0 google-cloud-pubsub==0.27.0 google-cloud-resource-manager==0.26.0 google-cloud-runtimeconfig==0.26.0 google-cloud-spanner==0.26.0 google-cloud-speech==0.28.0 google-cloud-storage==1.3.2 google-cloud-translate==1.1.0 google-cloud-videointelligence==0.25.0 google-cloud-vision==0.26.0 google-api-core==1.1.2 google-resumable-media==0.3.0 googleapis-common-protos==1.5.3 grpc-google-iam-v1==0.11.4 grpcio==1.6.3 html5lib==0.9999999 httplib2==0.10.3 idna==2.6 ipdb==0.10.3 ipython==6.2.1 ipython-genutils==0.2.0 iso8601==0.1.12 itsdangerous==0.24 jamo==0.4.1 jedi==0.11.0 Jinja2==2.9.6 joblib==0.11 librosa==0.5.1 llvmlite==0.20.0 m3u8==0.3.3 Markdown==2.6.9 MarkupSafe==1.0 matplotlib==2.1.0 monotonic==1.3 nltk==3.2.5 numba==0.35.0 numpy==1.13.3 oauth2client==3.0.0 parso==0.1.0 pexpect==4.2.1 pickleshare==0.7.4 ply==3.8 prompt-toolkit==1.0.15 proto-google-cloud-datastore-v1==0.90.4 proto-google-cloud-error-reporting-v1beta1==0.15.3 proto-google-cloud-logging-v2==0.91.3 proto-google-cloud-pubsub-v1==0.15.4 proto-google-cloud-spanner-admin-database-v1==0.15.3 proto-google-cloud-spanner-admin-instance-v1==0.15.3 proto-google-cloud-spanner-v1==0.15.3 protobuf==3.4.0 ptyprocess==0.5.2 pyasn1==0.3.7 pyasn1-modules==0.1.5 pydub==0.20.0 Pygments==2.2.0 pyparsing==2.2.0 python-dateutil==2.6.1 pytz==2017.2 requests==2.18.4 resampy==0.2.0 rsa==3.4.2 scikit-learn==0.19.0 scipy==0.19.1 simplegeneric==0.8.1 six==1.11.0 tenacity==4.4.0 #tensorflow-gpu==1.3.0 #tensorflow-tensorboard==0.1.8 tinytag==0.18.0 tqdm==4.19.2 traitlets==4.3.2 urllib3==1.22 wcwidth==0.1.7 Werkzeug==0.12.2 youtube-dl==2017.10.15.1 unidecode==1.0.22 inflect==0.2.5 -- 이렇게 구성 되어있습니다. Anaconda에서 3.6.12 버전 파이썬 쓰고있구요. 봐주셔서 감사합니다.
2.5K
1
0
kimho
kimho·2021-01-22
setuptools 버전을 46 아래로 낮추어 실행해보시기 바랍니다. pip3 install setuptools==45  
사용자 프로필· 5년

질문백엔드 개발자를 꿈꾸는 비전공자입니다. 처음 시작으로 자바 VS 파이썬 뭐가 좋을까요?

안녕하세요. 백엔드 개발자를 꿈꾸는 비전공 대학생입니다. 전공은 기계입니다. 이번에 부트캠프를 다녀볼까 고민중인데요. JAVA를 위주로 가르치는 곳(패xxxxx)이 있고, Python을 위주로 가르치는 곳(위xx)이 있더라구요. 유튜브도 보고, 검색도 해보고 여기저기 알아보니 python이 요즘 세계적으로 굉장히 핫하다고 하는데, 한국 기업들은 대부분 JAVA를 사용한다고 하더라구요. (채용글도 여러개 봤습니다) 어떤 걸 배워야할지(어느 곳을 다녀야 할지) 굉장히 고민되는데요. 고수님들 의견 주시면 감사하겠습니다.
1.2K
0
완지완지· 5년

[Django를 이용한 지역별 코로나맵 소스코드 배포]

[Django를 이용한 지역별 코로나맵 소스코드 배포]   안녕하십니까? 저희는 울산 전용 코로나맵을 제작한 지완김 (Kim Jiwan) , 전대성, 김태윤 (Tae Yoon Kim)이라고 합니다. 울산 코로나맵 주소: https://coronamap-ulsan.site/   코로나19가 전국적으로 급속도로 확산되며 전국을 대상으로한 코로나맵의 지역별 세세한 디테일이나 접근성에 문제점이 있다고 판단되었고, 이를 지역적으로 접근하여 시민들에게 더욱 정확하고 신속한 정보를 제공하기 위해 울산 지역을 한정으로 한 코로나맵을 제작하였습니다. 그리고 현재 배포 일주일만에 신규방문자가 4만명, 페이지 방문 수 10만회를 넘어가며 각종 메스컴에 소개되었습니다.   이러한 시민들의 관심으로부터 코로나 확진자 동선 및 마스크 판매처 등의 정보를 한 눈에 제공하는 어플이나 웹에 대한 지역별의 니즈가 있다는 것을 알게 되었습니다. 그래서 저희는 현재 저희가 울산만을 대상으로 한 프로젝트를 좀 더 가치있게 해보고자 장고를 통해 웹개발을 해보신 분이라면 누구나 빠르고 쉽게 각 지역별 코로나맵을 제작할 수 있도록 템플릿을 제작하였습니다. (장고 초보개발자 기준으로도 하루 이내에 충분히 서비스를 하실 수 있습니다.)
   저희가 제작한 서비스는 모바일과 데스크탑 화면 모두 호환되어있는 깔끔한 UI의 지역 단위 코로나맵이며, 세부 기능은 아래와 같습니다.   1. 지역 내 공적 마스크 판매처와 현황을 마커로 표시해 줍니다. 2. 30일 내에 확진자가 다녀간 동선을 주황색 마커로 표시해 줍니다. 다녀간 지 오래될 수록 색이 옅어집니다. 3. 공적 마스크 판매처와 현황, 확진자 정보, 확진자 동선 정보 등을 주기적으로 자동 업데이트하고 확진자 동선이 업데이트될 시 메일로 수신 가능합니다. 4. 지역 내 선별 진료소를 표시해줍니다. 5. 확진자 동선을 GUI로 쉽고 빠르게 추가할 수 있습니다.   아래의 깃헙의 README 가이드라인을 따라 프로젝트를 제작하여 배포하실 수 있습니다. 개인 공부차원에서 이용해보셔도 좋고, 괜찮다 싶으시면 배포하셔서 서비스 및 홍보를 통해 지역별 코로나19 방역에 도움을 보태주세요 :)
 깃헙 주소: https://github.com/nero96in/coronamap_deploy   관련 뉴스 자료 UBC 방송 : https://www.youtube.com/watch?v=nY5iOx6z9r8 울산 MBC : https://www.youtube.com/watch?v=IylaoigOnnA
1.6K
3
0
겨울이겨울이· 6년

[공고] python 개발자 구하고 있습니다. (엘라스틱서치 프로젝트 유경험자)

안녕 하세요 알티캐스트 최우진입니다. 현재 급하게 파이썬 개발자분을 찾고 있어 글 하나 올립니다.  관련하여 관심 있으신분은 아래 공고에서 연락 부탁드립니다. ^^:;;;   http://www.saramin.co.kr/zf_user/jobs/view?rec_idx=36987839&view_type=etc   너무 급하여 올리오니 양해 부탁드립니다. 
933
0
kimhokimho· 7년

2018년에 수요 많은 프로그래밍 언어 7가지

소프트웨어(SW) 개발 분야는 다이나믹하다. 몇 년 새 새로운 프로그래밍 언어, 프레임워크가 인기를 얻었다가 한순간 잊혀지기도 한다.​따라서 개발자들은 향후 커리어 발전을 위해 새로운 기술에 항상 관심을 가질 필요가 있다. 그렇다면 당장 내년에는 어떤 언어에 관심을 가져야 할까.​기업들이 연말연초 어떤 개발자를 채용하고 싶어하는........
1.6K
0