how to pass command line string arguments and compare them python -
i want comapre 2 strings passing 1 string command prompt, sample code, when pass c://python sample.py x, storing x1 x1=[' x '] if compare sys.argv[1:] string 'x' false, may comparing [' x '] == 'x', how should remove square brackets , single quotes around input after reads
import sys print sys.argv[1:] x1=sys.argv[1:] print x1
if x1=='x': print "true"
you trying compare list string here.
do
x1 = sys.argv[1] instead of
x1 = sys.argv[1:] python string
No comments:
Post a Comment