Str Argument in Python -


the code

def main(bar):     bar = str(bar)     print bar main(sys.argv[1:]) 

prints

['bar'] 

, instead of just

bar 

. should make input argument string? thanks. (python 2.5.2)

by passing sys.argv[1:] you're passing range of first argument every following argument. can of following independently desired results

# target 1 element when passing in main(sys.argv[1])  # or inside of function bar = str(bar[0]) 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -