SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

Rhodri James rhodri at kynesim.co.uk
Tue Nov 6 13:41:20 EST 2018


On 06/11/2018 18:10, srinivasan wrote:
> root:~/qa/test_library# python3 sd.py
>    File "sd.py", line 99
> *    cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)*
> *         ^*
> *SyntaxError: can't assign to literal*

Look at the 'cut' element of the pipeline.  You have used double quotes 
in a double quoted string without escaping them.  As a result, the 
interpreter thinks you are trying to assign the string literal " -f3" to 
the string literal "blkid -o export %s | grep 'Type' | cut -d"

-- 
Rhodri James *-* Kynesim Ltd



More information about the Python-list mailing list