What is the difference between shlex.split() and re.split()?
shlex.split() is designed to work like the shell’s split mechanism. This means doing things like respecting quotes, etc. >>> shlex.split(“this is ‘my string’ that –has=arguments -or=something”) [‘this’, ‘is’, ‘my string’, ‘that’, ‘–has=arguments’, ‘-or=something’] re.split() will just split on whatever pattern you define. >>> re.split(‘\s’, “this is ‘my string’ that –has=arguments -or=something”) [‘this’, ‘is’, “‘my”, “string'”, … Read more