I have the following variable assignment:
xpath_query="xpath='//a[@id="mylink"]'"
This is giving me an error in my pycharm editor and giving a syntax error when I run this code. What am I doing wrong?
when I hold the cursor over the red squiggle it says:"end of statement expected "
You have double quotes inside your " " block. so it becomes:
"xpath='//a[@id=" <-- stick together with --> "]'"
Hence it is a string syntax error.
To include "
inside " "
block, you can use \
to escape the character:
xpath_query="xpath='//a[@id=\"mylink\"]'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With