GentBG x PUSSTEEM - burning both STEEM and PUSS

Image
by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/gentbg-x-pussteem-burning-both-steem-and-puss Hello, this is @joviansummer(witness: @jswit), developer of GentBG project. I registered @gentbg account to PUSSTEEM about a week ago and donated some of my own PUSS token to @gentbg's EPUSS account. Now, @gentbg will burn STEEM and EPUSS at the same time. PUSSTEEM's boosting upvotes will help increasing baseline burning significantly. @gentbg's SP reward is delegate to @jsup to get automated upvotes, forming a baseline burning of liquid reward independent of other people's upvotes. Some may argue 100%(both liquid and SP reward) burning is much better, but I chose this approach to prevent @gentbg from becoming a spamming account. Constantly asking for upvotes via mentioning and commenting every week may eventually become a big annoyance to curators. That being said, anyone is welcome to participate in countering STEEM inflation by giving upvotes ...

파이썬의 딕셔너리(dict)에서 특정 키(key)가 존재하는지 확인하기

by joviansummer
original STEEMIT post: https://steemit.com/blog/@joviansummer/dict-key


key:value 형태로 구성되는 딕셔너리(dict) 형식의 변수에서 특정한 키(key)가 포함되어 있는지 확인하는 방법입니다.

일단 아래와 같이 x_dict라는 변수를 생각해 봅니다.

x_dict = { 'abc':100, 'def':50, 'xyz':99 }

x_dict에 "def"라는 키가 있는지 확인하려면 간단하게 if 조건문으로 가능합니다.

if 'def' in x_dict:
  print('x_dict에 키 def가 존재합니다.')
else:
  print('x_dict에 키 def가 존재하지 않습니다.')

딕셔너리의 value 항목을 리스트(list) 또는 딕셔너리로 구성하려면 실제 값을 할당하기 전에 초기화를 해 주어야 하는데, 이와 관련하여 간단한 예시를 메모해 둡니다.

target_list = { 'abc':[1,2,3] }
target_key = 'def'

if target_key in target_list:
  # value에 10을 추가, 리스트 형태이므로 append() 사용
  target_list[target_key].append(10)
else:
  print("target_list에 ", target_key, "키가 없습니다."
  # value를 리스트 형식으로 선언한 후에 value에 10을 추가
  target_list[target_key] = []
  target_list[target_key].append(10)

print(target_list)

{'abc': [1, 2, 3], 'def': [10]}

Comments

Popular posts from this blog

스티미언의 영향력 지수 계산

jsup/avle code update - you don't have to write post everyday

jsup/avle 보팅 코드 갱신 - 1일1포스팅 강박에서 벗어나기