这个absl库是建立Python应用的python代码集合。这些代码是从Google自己的Python代码基础上收集来的,被用于测试和工业中。
为了安装这个库,简单运行下面代码:
pip install absl-py
#"""absl_example""" Example1.py
"""Test helper fot smoke_test.sh"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
from absl import app
from absl import flags
from absl import logging
FlAGS = flags.FLAGS
flags.DEFINE_string('echo', None, 'Test to echo')
flags.DEFINE_integer('times', 10, 'how many times to print the string')
def main(argv):
del argv # Unused
print("Running under Python {0[0]}.{0[1]}.{0[2]}".format(sys.version_info),
file = sys.stderr)
logging.info('echo is %s', FlAGS.echo)
for _ in range(FlAGS.times):
print('Hello Python!')
if __name__ == '__main__':
app.run(main)
python Example1.py --name = 'David' --times = 6
(ANACONDA01) G:\Project\Learn_python3\Demo07>python Example1.py --echo=‘David’ --times=6
Running under Python 3.6.10
I0223 09:54:01.403743 8544 Example1.py:28] echo is ‘David’
Hello Python!
Hello Python!
Hello Python!
Hello Python!
Hello Python!
Hello Python!