[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...

파이썬에서 실행 명령에 인자(argument) 지정

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


파이썬 스크립트를 실행할 때 실행 명령에 인자(argument)를 지정할 수 있습니다. 예를 들어 인자를 확인해서 이를 그대로 출력하는 스크립트 test.py를 만든다고 생각해 보겠습니다.

아래와 같은 실행 결과를 주는 스크립트입니다.

python3 test.py hello

test.py hello

python3 test.py hello world

test.py hello world

위의 스크립트는 아래와 같은 내용으로 작성되었습니다.

import sys

for arg in sys.argv:
  print(arg)

실행 명령의 인자는 sys.argv에 저장되며, 리스트(list) 형식입니다. 위의 예시에서는 for 반복문으로 sys.argv[0]부터 차례로 출력하였습니다.

2번째 예시의 경우(실행 명령: python3 test.py hello world) sys.argv에는 아래와 같이 값이 할당될 것입니다.

sys.argv[0]: 'test.py'(스크립트의 이름) sys.argv[1]: 'hello' (첫번째 인자) sys.argv[2]: 'world' (2번째 인자)

Comments

Popular posts from this blog

[ENG] jsup 2.0 - make your upvote great again

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

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