Passing meta-characters to Python as arguments from command line

前端 未结 4 794
一生所求
一生所求 2020-12-11 03:37

I\'m making a Python program that will parse the fields in some input lines. I\'d like to let the user enter the field separator as an option from the command line. I\'m usi

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 04:02

    The quick and dirty way is to to eval it, like this:

    eval(options.delimiter, {}. {})
    

    The extra empty dicts are there to prevent accidental clobbering of your program.

提交回复
热议问题