Skip to content

Instantly share code, notes, and snippets.

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