How do you protect yourself from missing comma in vertical string list in python?

前端 未结 4 717
春和景丽
春和景丽 2021-01-12 04:07

In python, it\'s common to have vertically-oriented lists of string. For example:

subprocess.check_output( [
  \'application\',
  \'-first-flag\',
  \'-secon         


        
4条回答
  •  死守一世寂寞
    2021-01-12 04:27

    Here's another alternative:

    subprocess.check_output('''
    application
    -first-flag
    -second-flag
    -some-additional-flag
    '''.split())
    

    Let Python insert the commas for you, this is especially useful for long lists of strings in configuration files

提交回复
热议问题