jsup 2.1 - investor's relief (experiment on separation of investment and SNS)

by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/jsup-2-1-investor-s-relief-experiment-on-separation-of-investment-and-sns Hello, this is @joviansummer(witness: @jswit). I'm starting a new experiment regarding my @jsup vote service. The purpose of this experiment is to separate STEEM investment and social interaction(posting/commenting). For many people, writing a post daily(literally 365 posts per year) is not easy. It's not fun, and mandatory daily post only written for self-voting delegation service tends to result in useless low-quality content. I hope this new function of @jsup will reduce those posts, and also make it a bit more easy to invest in STEEM without worrying about daily posting. I think pressure of daily posting significantly undermines Steem as SNS. It's not fun. This is how it works: From 11:45 PM to 11:50 PM every night(reference time zone is GMT+9), @jsup checks if eligible delegators wrote something and received daily v...

파이썬에서 특정 파일이 존재하는지 확인하기

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


인터넷에서 찾아봤다가 잊어버렸다가 나중에 다시 찾아보는 수고를 방지하기 위해서 현재 진행중인 작업과 관련하여 필요한 내용들을 시간 날 때마다 메모해 두려고 합니다.

파이선에서 파일 존재 여부를 확인하는 예시입니다. os 모듈을 활용합니다.

import os
# 현재 디렉토리 정보를 CUR_DIR에 할당
CUR_DIR = os.getcwd()
# 디렉토리 출력
print(CUR_DIR)

현재 디렉토리에 joviansummer.txt 파일이 존재하는지 확인합니다.

# 확인 대상 파일(리눅스 기준으로 구분자 "/" 사용)
target_file = CUR_DIR + "/joviansummer.txt"

# 대상 경로(path) 존재 여부 확인
if os.path.exists(target_file):
  print("경로가 존재합니다")
else:
  print("경로가 존재하지 않습니다")

os.path.exits()는 대상이 파일인지 디렉토리인지 관계 없이 해당 경로가 존재할 경우에 True가 됩니다. 대상이 "파일"인지를 특정해서 확인하기 위해 os.path.isfile()을 함께 AND(교집합) 조건으로 묶어줍니다.

# 대상 경로가 존재하고, 그것이 파일인지 확인
if (os.path.exists(target_file) and (os.path.isfile(target_file)):
  print("파일이 존재합니다.")
else:
  print("파일이 존재하지 않습니다.")

Comments

Popular posts from this blog

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

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

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