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 ...

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

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포스팅 강박에서 벗어나기