Python3 flags

版权声明:文章来自 https://www.lucien.ink,转载请注明文章出处 https://blog.csdn.net/xs18952904/article/details/89213519

原文地址:https://www.lucien.ink/archives/412/

https://pasteme.cn/5872

# 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 --helpmain.py -help 获取帮助信息。

展开阅读全文

没有更多推荐了,返回首页