【发布时间】:2015-01-30 23:59:08
【问题描述】:
我想知道在 python 中是否可以从变量中提取某些整数并将其保存为单独的变量以供以后使用。
例如:
str1 = "numberone=1,numbertwo=2,numberthree=3"
newnum1 = [find first integer from str1]
newnum2 = [find second integer from str1]
answer = newnum1 * newnum2
print(answer)
【问题讨论】:
-
你的输入是什么样的???
-
是的,你当然可以解析字符串来提取你想要的。
-
检查stackoverflow.com/questions/11339210/…,尝试一下,如果失败了,展示你尝试过的东西