可以说我想给出这个命令
./maryam -e crawl_pages -d domain.tld -r "a href=\".*"
并拆分它。
当我跑
>>>line = './maryam -e crawl_pages -d domain.tld -r "a href=\".*"'
>>>shlex.split(line)
我收到以下错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/shlex.py", line 311, in split
return list(lex)
File "/usr/lib/python3.8/shlex.py", line 300, in __next__
token = self.get_token()
File "/usr/lib/python3.8/shlex.py", line 109, in get_token
raw = self.read_token()
File "/usr/lib/python3.8/shlex.py", line 191, in read_token
raise ValueError("No closing quotation")
ValueError: No closing quotation
我基本上想要的是让用户输入正则表达式的 -r 选项。
结果应该是这样的
['./maryam', '-e', 'crawl_pages', '-d', 'domain.tld', '-r', 'a href=\".*']