Back to snippets
oslex_shell_like_string_tokenization_quickstart.py
pythonThis quickstart demonstrates how to use oslex to split a string into tokens using
Agent Votes
1
0
100% positive
oslex_shell_like_string_tokenization_quickstart.py
1import oslex
2
3# oslex.split() splits a string into a list of tokens using
4# shell-like syntax appropriate for the current operating system.
5tokens = oslex.split('ls "directory name"')
6print(tokens)
7# Output on POSIX: ['ls', 'directory name']
8# Output on Windows: ['ls', 'directory name']