Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 12, 2020 07:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Use "Fire" module to input arguments
'''
python3 "file.py" -arg arg
'''
#install fire
pip install fire
#Main code
import fire
def printHelloWorld():
return 'Hello World!'
def name(name):
return 'your name is {}.'.format(name)
if __name__ == '__main__':
fire.Fire() #使用fire.Fire()啟動Fire模組
'''
Example1:
$ python fire_test.py name "Bob
Output:
your name is Bob
Example2:
$ python fire_test.py printHelloWorld
Output:
Hello World!
''''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment