# main.py
from absl import app, flags
FLAGS = flags.FLAGS
flags.DEFINE_string('test', None, 'comma separated list of GPU(s) to use.')
def main(argv):
del argv
if FLAGS.test:
print(FLAGS.test)
else:
print('test is not set')
if __name__ == '__main__':
app.run(main)
Macbook Pro:~ LucienShui$ python3 main.py --test 1
1
Macbook Pro:~ LucienShui$ python3 main.py -test 1
1
Macbook Pro:~ LucienShui$ python3 main.py --test=1
1
Macbook Pro:~ LucienShui$ python3 main.py -test=1
1
main.py --help
或 main.py -help
获取帮助信息。