-2
이 정의에서 나는 optparse를 사용하여 명령 행에서 일부 argumets를 받아 들인다. 그래서, 내 질문에 메서드 add_option dest, 개체에서 호출 할 수있는 이름 가진 속성을 만드는 방법입니다.필자는 객체가 파이썬에서 어떻게 작동하는지 더 잘 이해하려고 노력하고있다.
def main():
parser = optparse.OptionParser('usage%prog ' + \
'-H <target host> -u <user> -F <password list>')
parser.add_option('-H' , dest='tgtHost', type='string', \
help='specify target host')
parser.add_option('-u' , dest='user', type='string', \
help='specify the user')
parser.add_option('-F', dest='passwdFile', type='string', help='specify password file')
(options, args) = parser.parse_args()
host = options.tgtHost
passwdFile = options.passwdFile
user = options.user
그것은 뭔가'**'s의 무리를 도입 코드 서식에게 일어난 것 같습니다. –
* 작동 방법 *을 알고 싶다면'add_option (...) '소스를 탐색 할 수 있습니다 - https://hg.python.org/cpython/file/2.7/Lib/optparse.py#l1008 –
고마워요! Thats 아주 좋은 출발. –