STEEM POWER retention ratio of top 50 witnesses

by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/steem-power-retention-ratio-of-top-50-witnesses Hello, this is @joviansummer(witness: @jswit). Some time ago there was a bit of discussion on discord witness chanel about witnesses' power-down/cashing-out. So out of curiosity I just checked current ratio of witnesses' own STEEM POWER(VESTS) and all-time producer reward(VESTS). The ratio is calculated by the following simple formula: ratio(%) = account's own SP(MV) / all-time producer reward SP(MV) * 100% Ratio value less than 100% indicates power-down. If witness does additional power-up or gets other types of reward(e.g., curation reward), the ratio may exceed 100%. This does not take witness' other accounts into consideration. All-time producer reward data is from @steemchiller's SDS API. Here is the result: rank account own_sp prod_sp ratio 1 justyy 2188.411MV 1284.2MV 170.41% 2 steemchiller 982.134MV 124...

파이썬에서 정규표현식(regex)을 이용한 문자열 검색

by joviansummer
original STEEMIT post: https://steemit.com/blog/@joviansummer/regex


파이썬에서 정규표현식(regular expression)을 이용해서 검색 조건에 일치하는 문자열인지 확인하는 방법입니다.

예시를 보겠습니다. 문자열 'abc', 'def', '123', '1abc' 이렇게 4개를 묶어 리스트(list)로 만들고 영문 소문자([a-z])를 검색해 봅니다.

import re

# 리스트 생성
str_list = ['abc', 'def', '123', '1abc']

# 적용할 정규표현식을 컴파일하여 regex에 할당
regex = re.compile('[a-z]')

이제 for 반목문으로 str_list에 속한 문자열들에 대해서 검색을 합니다. 우선 match()를 사용해 봅니다.

for i in str_list:
  if regex.match(i):
    print(i)

abc def

match()는 문자열 처음부터 조건과 일치하는지 검색합니다. 위의 예시에서는 문자열 'abc'와 'def'가 처음부터 영문 소문자로 시작하므로 조건에 부합하여 줄력되었습니다.

search()는 문자열 전체에 대해 일치하는 부분이 있는지를 검색합니다.

for i in str_list:
  if regex.search(i):
    print(i)

abc def 1abc

문자열 '1abc'의 경우 영문 소문자로 시작하지 않기 때문에 match()에서는 조건에 부합하지 않지만, 영문 소문자를 포함하고 있으므로 search()에서는 조건에 부합되어 출력됩니다.

findall()은 조건에 맞는 문자열을 모두 찾아서 리스트 형태로 가져옵니다.

x = 'hello'
y = regex.findall(x)
print(y)

['h', 'e', 'l', 'l', 'o']

문장으로부터 영문 소문자 단어를 분리하려면 아래와 같이 해 볼 수 있겠습니다.

# 영문 소문자가 1번 이상 반복: 정규표현식 [a-z]+
regex2 = re.compile('[a-z]+')
x = 'my name is joviansummer.'
y = regex2.findall(x)
print(y)

['my', 'name', 'is', 'joviansummer']

Comments

Popular posts from this blog

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

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

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