1

在项目的 Python 代码中micropython,有时import语句位于函数内部。

def main():
    import argparse
    cmd_parser = argparse.ArgumentParser(description='A tool to work with MicroPython .mpy files.')
    cmd_parser.add_argument('-d', '--dump', action='store_true',
        help='dump contents of files')
    cmd_parser.add_argument('-f', '--freeze', action='store_true',
        help='freeze files')
    ...

这是好习惯吗?
这有技术原因吗?

4

0 回答 0