Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经从 powershell 向脚本输入了 3 个参数,我希望其中一个是浮点数 0.0。然后我尝试使用 time = int(time) 将此值从字符串转换为整数,但出现错误。任何人都知道如何让我的变量在程序中保存我的浮点数?谢谢你。
time = int(float(time))
你确定你想要一个整数吗?"0.0"如果你想要 integer ,传入是没有意义的0。听起来您应该传入"0",或者应该将其存储为浮点数。
"0.0"
0
"0"
要将其存储为浮点数,只需使用
time = float(time)