GentBG - why bother to burn STEEM?

Image
by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/gentbg-why-bother-to-burn-steem GentBG - a new experiment to burn STEEM Hello, this is @joviansummer(witness: @jswit). I'd like to briefly explain why I bothered to start @gentbg experiment. Unlike bitcoin, STEEM has no supply limit. As long as STEEM exists, newly minted STEEM will be added to total supply. If we can't maintain corresponding demand or reduce supply, downward pressure on STEEM price can be a big challenge. @gentbg project is an experiment to reduce STEEM supply by burning. @gentbg will burn liquid author reward and delegate SP reward to @jsup to get amplified upvotes. The main purpose is to create a perpetual STEEM burning loop. I added a bit of fun factor via AI-generated images, to incentivize giving upvotes to @gentbg's posts. If you have some spare voting power, you can contribute to burning STEEM by giving upvotes to @gentbg's posts. Initial run of this experiment wil...

파이썬에서 문자열에 특정한 문자열이 포함되었는지 확인

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


문자열(str) 형식의 변수에 특정한 문자열이 포함되어 있는지 확인하려면 find()를 사용합니다. 아래와 같이 간단한 예시를 보겠습니다.

x = 'hello world'
x.find('hello')

위의 x.find('hello')는 문자열 x에 hello가 포함되어 있을 경우 해당 문자열이 시작되는 위치를 반환하게 됩니다. 이 예시에서 x의 맨 처음에 hello가 있으므로 반환되는 값은 0입니다. (위치는 0부터 셉니다.)

변수에 할당하지 않고 문자열 자체에 대해서도 find()를 사용할 수 있습니다.

# 첫번째 등장하는 o의 위치 찾기 
'hello world'.find('o')

만약 일치하는 문자열이 없을 경우에는 -1을 반환합니다.

x.find('abcd')

위의 예시처럼 문자열 "abcd"를 찾는다면 "hello world"에는 포함되어 있지 않으므로 -1을 반환할 것입니다.

따라서, 반환되는 값이 0 이상이면 문자열이 포함되어 있는 것이라고 판단할 수 있습니다. if 조건문으로 아래와 같이 문자열 포함 여부를 확인할 수 있습니다.

x = 'hello world'
if x.find('hello') >= 0:
  print('x에 hello가 포함되어 있습니다. 위치는 ', x.find('hello'), '입니다.')
else:
  print('x에 hello가 포함되어 있지 않습니다.')

예시를 하나 더 보겠습니다.

x = 'hello world'
y = 'abcd'
if x.find(y) == -1:
  print('x에 ', y, '가 포함되어 있지 않습니다.')

Comments

Popular posts from this blog

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

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

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