3 odpowiedzi
+ 5
Converts an object to an integer (if possible).
a = '25' # string
b = '2'
print(a + b) # strings are concatenated
# output: '252'
print(int(a) + int(b)) # strings are treated as integers
# output: 27
+ 4
int function in Python convert a float number or a string to number.
int(2.3)
》 2
int("44")
》 44
if you enter a integer for this function it will back a copy of your number.
int(144)
》 144
you can read more here:
https://docs.python.org/3/library/functions.html#int
- 1
it converts the value with a type string to an integer