Hướng dẫn dùng casted meaning python
Ngày đăng:
04/09/2022
Trả lời:
0
Lượt xem:
195
Specify a Variable TypeThere may be times when you want to specify a type on to a variable. This can be done with casting. Python is an object-orientated language, and as such it uses classes to define data types, including its primitive types. Casting in python is therefore done using constructor functions:
ExampleIntegers: x = int(1) # x will be 1 Try it Yourself » ExampleFloats: x = float(1) # x will be 1.0 Try it Yourself » ExampleStrings: x = str("s1") # x will be 's1' Try it Yourself » |