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.
Start= 1 End= 10 change=0.5 for Start in range(Start,End,change) : print(Start)
这段代码有什么问题?我在学校工作,似乎无法将 for 循环与字符串一起使用。
Python不range支持浮点increment,因此出现错误:
range
increment
DeprecationWarning: integer argument expected, got float
所以你在 0.5 的值需要是一个整数,你可以使用数学来获得相同的输出
Start= 2 End= 21 change=1 for Start in range(Start,End,change) : print(Start*0.5)