Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 12, 2020 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e96031413/a9764c260bf6f551d2d10e3f801f4a88 to your computer and use it in GitHub Desktop.
Save e96031413/a9764c260bf6f551d2d10e3f801f4a88 to your computer and use it in GitHub Desktop.
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