[ENG] STEEM Security update - added power down alert

by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/eng-steem-security-update-added-power-down-alert STEEM Security - receive STEEM alert messages via Discord Hello, this is @joviansummer(witness: @jswit). STEEM Security code has been revised. Previously, STEEM Security was sending alert message via discord for the following 3 kinds of operations: sending STEEM/SBD to another account changing SP delegation account update Now, power down operation has been added. If there is a power down operation, you will also receive alert message. Please check the original post of the above link for detailed information on how to use the service. Thank you for reading, and have a wonderful day! @joviansummer's STEEM projects @jswit witness: I'm running a STEEM witness node. I'd really appreciate it if you vote for my witness account @jswit. ( https://steemitwallet.com/~witnesses ) [ENG] Introducing @jswit witness project @jsup curation: [ENG] Int...

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

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

[ENG] jsup 2.0 - make your upvote great again

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

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