๋ฐ˜์‘ํ˜•

๐Ÿ“‚ Programming/Python 3

[Python] datetime ๋ชจ๋“ˆ ์ •๋ฆฌ

import datetime now = datetime.datetime.now() one_day = datetime.timedelta(days=1) one_hour = datetime.timedelta(hours=1) # ํ˜„์žฌ ๋‚ ์งœ์™€ ์‹œ๊ฐ„ ์ถœ๋ ฅ # 2023-04-21 01:21:35.277992 print(f'now : {now}') # ํ˜„์žฌ ์—ฐ๋„์™€ ๋‚ ์งœ๋งŒ ์ถœ๋ ฅ # 2023-04-21 print(f'now.date() : {now.date()}') # ํ˜„์žฌ ์‹œ๊ฐ„๋งŒ ์ถœ๋ ฅ # 01:21:35.277992 print(f'now.time() : {now.time()}') # ํ˜„์žฌ ์—ฐ๋„๋งŒ ์ถœ๋ ฅ # 2023 print(f'now.year : {now.year}&#3..

[Python] collections Counter ์‚ฌ์šฉ๋ฒ•

collections.Counter dict์˜ ์„œ๋ธŒ ํด๋ž˜์Šค๋กœ ์š”์†Œ๊ฐ€ ํ‚ค๊ฐ€ ๋˜๊ณ  ๊ฐœ์ˆ˜๊ฐ€ ๊ฐ’์ด ๋˜์–ด ํŽธ๋ฆฌํ•˜๊ฒŒ ๊ฐœ์ˆ˜๋ฅผ ์…€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ์ œ 1 import collections S = "aaabbccdd" S_counter = collections.Counter(S) print(S_counter) for a, b in S_counter.items(): print(a, b) ''' ์‹คํ–‰ ๊ฒฐ๊ณผ Counter({'a': 3, 'b': 2, 'c': 2, 'd': 2}) a 3 b 2 c 2 d 2 ''' ์˜ˆ์ œ 2 import collections L = ["zz", "zz", "zz", "aa", "ab", "ab..

๋ฐ˜์‘ํ˜•