<分区>
我是 Python 的新手。
When I have created a simple object in swift:-
let one = 7.0
let two = 2.0
var three = one / two
print(three)
let first = 7
let second = 2
let third = CGFloat(first/second)
print(third)
输出结果是:- 3.5 和 3.0
I am creating simple objects in python. Using Python in the terminal.
>>> 7/2.
3.5
>>> float(7/2)
3.0)
输出结果是:- 3.5 和 3.0
为什么是 7/2。自动读取整数以 float 。当我这样声明两个不同的整数时:-
>>> a = 7
>>> b = 2
>>> c = a / b.
显示错误。语法无效。
Python 如何在 7 月 2 日生成自动结果。并得到结果。
在对象中使用时显示错误。