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/2v14rm


파이선에서 텍스트 파일을 읽거나 쓰는 방법입니다.

먼저 텍스트 파일을 읽으려면 open() 함수에서 읽고자 하는 파일을 읽기(r) 모드로 지정합니다.

# test.txt 파일을 읽기 모드로 열어서 파일 객체 f에 할당
f = open('test.txt', 'r')

파일의 내용을 한꺼번에 읽을 경우에는 read()를 사용합니다. 읽은 후에는 열려 있는 파일을 닫아줍니다.

# 파일 객체 f에 의해 열려 있는 파일을 읽어서 문자열 전체를 변수 x에 할당
x = f.read()
f.close()

위의 예시에서는 여러줄로 된 내용 전체가 하나의 변수 x에 할당되었습니다. 만약 내용을 한줄씩 읽고 싶다면 readline()을 사용합니다.

예를 들어 파일의 내용을 한줄씩 읽어서 리스트(list)의 원소로 추가할 경우 아래와 같이 할 수 있겠습니다.

# 리스트 초기화
x_list = []
# 파일 열기
f = open('test.txt', 'r')
# 한줄씩 읽기 시작
while True:
  line_str = f.readline()
  if not line_str:
    # 읽은 줄이 null string일 경우 while 반복문 중단
    break
  else:
    # 리스트에 원소 추가
    x_list.append(line_str)
f.close()

Comments

Popular posts from this blog

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

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

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