jsup.GEN - working on image-to-image generation with AI

Image
by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/jsup-gen-working-on-image-to-image-generation-with-ai Hello, this is @joviansummer(witness: @jswit). I'd like to share what I'm working on regarding my experintal jsup.GEN project, which tries to connect image generation AI with Steemit. Currently, jsup.GEN provide function to generate image from test prompt(txt2img). This function is interesting, but it's not easy to generate exactly what you want because you need to explain the image in detail with multiple keywords in English. Thus, I think it's more useful to have a function to generate image from existing reference image. I'm working on this image-to-image function, and thinking about two methods to implement it. The first method is to provide 2 commands as follows: !gen_t : This command focuses more on text prompt than reference image. The result may be quite different from reference because text prompt will have much more in...

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

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 보팅 코드 갱신 - 1일1포스팅 강박에서 벗어나기

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