Parsing Flags in Python -


I am trying to parse the given arguments and flags manually to the string. For example, if I

"- flag 1 'is the argument" "

I am hoping to get back

< P> for any arbitrary number of flags in the string ['- flag1', 'this argument is]]

.

I find out For example, if I come from ( parser argparse )

Code> parser.parse_args ("- flag1 'This argument is" ". Partition ())

" - flag1' This argument is "". Partition () "< / Code>

becomes

['flag1', '' it '', '' '' '' '' '' '' logic '']

Which I do not expect. Is there an easy way to do this?

You are in luck; There is an easy way to do this Use the. As you would like

  & gt; & Gt; & Gt; Import Shells & gt; & Gt; & Gt; Shlex.split ("- flag1 'this argument is" ") [' - flag1 ',' this argument ']  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -