일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- and
- or
- Python
- decorator
- FOR
- SQL
- DART
- js
- WECODE
- index
- range
- lambda
- enumerate
- sum
- slice
- Sorted
- If
- join
- count
- MAX
- map
- LOWER
- 파이썬
- Algorithm
- iNT
- len
- 위코드
- STR
- split
- list
- Today
- Total
목록join (53)
코드로 우주평화
Sqlalchemy 로 ORM 영역에서 join 을 하려고 할 때 joinedload 를 자주 사용한다. 그런데 joinedload 방식은 복수의 ORM 객체를 불러올 때에 다음처럼 에러가 발생할 수 있다. sqlalchemy.exc.InvalidRequestError: The unique() method must be invoked on this Result, as it contains results that include joined eager loads against collections 결론부터 말하자면 메시지의 내용대로 unique() 를 추가하면 된다. 아래처럼 말이다. ... res = await session.execute(stmt) res.scalars().all() # X res.sca..
Happy Holidays fellow Code Warriors! Santa's senior gift organizer Elf developed a way to represent up to 26 gifts by assigning a unique alphabetical character to each gift. After each gift was assigned a character, the gift organizer Elf then joined the characters to form the gift ordering code. Santa asked his organizer to order the characters in alphabetical order, but the Elf fell asleep fro..
Filter the number Oh, no! The number has been mixed up with the text. Your goal is to retrieve the number from the text, can you return the number back to its original state? Task Your task is to return a number from a string. Details You will be given a string of numbers and letters mixed up, you have to return all the numbers in that string in the order they occur. Solution: def filter_string(..
I will give you an integer. Give me back a shape that is as long and wide as the integer. The integer will be a whole number between 1 and 50. Example n = 3, so I expect a 3x3 square back just like below as a string: +++ +++ +++ Solution: def generate_shape(n: int) -> str: return "\n".join("+" * n for i in range(n))
altERnaTIng cAsE ALTerNAtiNG CaSe Define String.prototype.toAlternatingCase (or a similar function/method such as to_alternating_case/toAlternatingCase/ToAlternatingCase in your selected language; see the initial solution for details) such that each lowercase letter becomes uppercase and each uppercase letter becomes lowercase. For example: "hello world".toAlternatingCase() === "HELLO WORLD" "HE..
Write a function partlist that gives all the ways to divide a list (an array) of at least two elements into two non-empty parts. Each two non empty parts will be in a pair (or an array for languages without tuples or a structin C - C: see Examples test Cases - ) Each part will be in a string Elements of a pair must be in the same order as in the original array. Examples of returns in different l..
Create a function that returns the CSV representation of a two-dimensional numeric array. Example: input: [[ 0, 1, 2, 3, 4 ], [ 10,11,12,13,14 ], [ 20,21,22,23,24 ], [ 30,31,32,33,34 ]] output: '0,1,2,3,4\n' +'10,11,12,13,14\n' +'20,21,22,23,24\n' +'30,31,32,33,34' Array's length > 2. Solution: def to_csv_text(array): return '\n'.join(','.join(map(str, i)) for i in array)
Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. Example: 5.5589 is rounded 5.56 3.3424 is rounded 3.34 Solution: def two_decimal_places(n: float) -> float: l, r = str(n).split(".") r = str(round(int("1"+r[:5]), -3)) return float(".".join([l, r[1:3]])) def two_de..
Write a function that returns a string in which firstname is swapped with last name. Example(Input --> Output) "john McClane" --> "McClane john" Solution: def name_shuffler(str_): return " ".join(str_.split(" ")[::-1])
Your boss decided to save money by purchasing some cut-rate optical character recognition software for scanning in the text of old novels to your database. At first it seems to capture words okay, but you quickly notice that it throws in a lot of numbers at random places in the text. Examples (input -> output) '! !' -> '! !' '123456789' -> '' 'This looks5 grea8t!' -> 'This looks great!' Your har..