开发者

how to use the output/value of variable in python

开发者 https://www.devze.com 2023-03-28 05:58 出处:网络
I\'m learning python.So here\'s what I\'m after: Inside a python script I have the following: back_minutes1 = int(sys.argv[2])

I'm learning python. So here's what I'm after:

Inside a python script I have the following:

back_minutes1 = int(sys.argv[2])
back_minutes = timedelta(minutes=back_minutes)

This works fine, but I'm essentially creating a 'trash variable' to make it work. If this wer开发者_JAVA百科e say bash, I could probably do something like

back_minutes = timedelta(minutes=`int(sys.argv[2])`)

This, of course doesn't work. What's the pythonic way to do this without creating this throw-away variable?


Why not

back_minutes = timedelta(minutes=int(sys.argv[2]))
0

精彩评论

暂无评论...
验证码 换一张
取 消