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

by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/jsup-avle-code-update-you-don-t-have-to-write-post-everyday Hello, this is @joviansummer, developer of @jsup and@avle voting service. Voting service code for @jsup and @avle has been updated. I had been considering this update for a while, and recently I could come up with detailed implementation plan which resulted in a relatively swift code revision. The new added feature is capability to give daily upvote to the first thing you write for the day(timezone GMT+9) regardless of post or comment/reply. Writing a post everyday can be challenging. In that case, you can write a reply to receive daily upvote because writing a reply everyday is much easier and also a good way to engage in your community. Writing a post everyday just to get an upvote can be very tedious and exhausting, and post itself could easily become low-quality. There may be people who enjoy writing a post everyday, but we can't ignore th...

파이썬에서 파일 확장자 분리

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


파이썬에서 간단하게 파일명에서 확장자만 따로 떼어내서 확인할 수 있습니다. os 모듈을 import하고 os.path.splitext() 함수를 사용하면 됩니다.

import os

filename = "/test/my_data.tmp.txt"
result = os.path.splitext(filename)
print(result)

('/test/my_data.tmp', '.txt')

확장자와 나머지 부분을 분리해서 위와 같이 투플(tuple)을 만들어 줍니다. 투플은 리스트(list)와 비슷하지만 값을 변경할 수 없다는 점이 다릅니다. 리스트와 마찬가지로 인덱스로 필요한 부분을 가져와서 쓰면 됩니다.

print(result[0])

/test/my_data.tmp

print(result[1])

.txt

파일의 확장자에 따라 뭔가 다른 작업을 해야 할 때 편리합니다.

``` ext_str = os.plath.splitext(filename)[1] if ext_str == ".txt": print("확장자가 .txt입니다.")

Comments

Popular posts from this blog

Nuitka - 파이썬 스크립트를 바이너리 실행 파일로 변환

[ENG] jsup 2.0 - make your upvote great again

[EN] STEEM-services: dapps/services webpage with sort and search functions