python getopt 模組
from getopt import getopt
getopt(["--testing=hello.txt","-a","-l","-f foo.txt"],"alf:",["testing="])
>>
([('--testing', 'hello.txt'), ('-a', ''), ('-l', ''), ('-f', ' foo.txt')], [])
getopt(["-a","-l","-f foo.txt","--testing=hello.txt"],"alf:",["testing="])
>>
([('-a', ''), ('-l', ''), ('-f', ' foo.txt'), ('--testing', 'hello.txt')], [])
getopt(["-a","-l","-f foo.txt"," --testing=hello.txt"],"alf:",["testing="])
>>
([('-a', ''), ('-l', ''), ('-f', ' foo.txt')], [' --testing=hello.txt'])
#" --testing=hello.txt"切記裡面包含了空格 就會比對錯誤
沒有留言:
張貼留言