I'm going to define a class, and in particular, what I'm going to do, is walk through what that says.
我们碰到了一个问题,这个问题就是,我们想要建立,一个抽象数据类型。
Data's what we expect. It's our way of representing fundamentally the kinds of information we want to move around.
数据是我们一直需要的,它是用来表达我们想要操作的,数据类型的基本方式,这里。
int So, primitive type besides those three types, we have ints which are just integers which are similarly 32 bits.
除了这三种类型外,还有一种最原始的数据类型,32比特整数。
And here, I'm going to suggest we've seen numbers, we've seen strings, and I'm going to add Booleans here as well.
我要提醒下大家我们学习过数字数据了,学习过字符串了,今天还要学习布尔类型,这是当我们谈到条件的时候。
Now when the only types we're dealing with are the built-in types, the ones that came with the programming language, that doesn't really matter.
现在我们对付的数据类型,只有内置的数据类型,也就是编程语言固有的类型。
Alright, so it turns out there're two other useful types that you don't get for free out of the box.
我们还是回到这里,还有两种很有用的数据类型,这两种都不用担心内存不足。
You can compel the compiler to treat some value as a different type of value, at least if it makes intuitive sense that that should be possible.
你可以控制编译器处理,不同类型的数据,至少我们凭直觉,它应该是可能的。
In terms of primitive data, what we saw were two kinds: Right?
在基础数据方面,我们上节课学了两种类型对不对?
We saw, associated with that primitive data, we have ways of taking data in and creating new kinds of data out, or new versions of data out, so we have operations.
我们可以取得输入的数据然后,创建新的类型的输出数据,或者新的版本的输出数据,这就是我们说的操作。
I went from this description, it gives me some information. I need to have a particular type.
我从这些描述出发,它给了我一些信息,我需要一些特定类型的数据。
And the only thing that's differing is the name of the type and the name of the variable I'm using.
其中唯一的区别是数据类型的名字,和我使用的变量名字。
- >> Is there a data type for representing 1,024 bits or -- >> David: Good question.
>,有没有能表示1024位大小的数据类型或-,>>,大卫:好问题。
The reason I want to point this out to you is, if we go back up to the kinds of data objects we started with, floats, ints, strings, they actually behave the same way.
我要为大家指出这一点的原因是,如果我们想一下以前讲过的,数据类型的种类,浮点数,整数,字符串,它们实际上有相同的行为方式。
And if you think about it, associated with each - one of those data types is a set of functions it's intended to apply to.
你会发现每个类型都有,与之对应的一个集合的操作,有的时候这些操作,有的时候某个操作可以,应用于多种数据类型。
And over the next couple of days, you'll see what we mean by this in detail.
就是抽象数据类型,你可以在网上看到这两个术语。
And thankfully with 64-bit values can we do so, but sure enough will we run out of space, even with those types of types.
幸亏有64位的数值,我们才能做到如此,但是我们的空间真的会用完,即使有这样的数据类型。
They're a third kind of value that we saw when we started talking about conditions.
要去学习的第三种数据类型,我们已经学习过了,通过基础数据。
So I'm going to suggest that we've looked at three different kinds of things.
那么我提醒下大家我们学了三种类型的,东西了,我们学习过数据类型。
But out of the box, you generally just get these so-called "primitives."
但是立即可以用的,我们通常只有这些所谓的“基本数据类型“
This is a type of number that we'll see in a bit.
这只是一种数据类型,不久后我们就会看到。
And those are four of the data types we've discussed thus far.
这是我们到现在为止学习了的四个数据类型。
We want to do the same thing, but with our data types.
我们想要创建数据类型和函数,或者我们会叫他们方法。
And we've only just begun using it, but it has just a bunch GetInt GetString GetDouble of very useful functions like GetInt, GetString, GetDouble, And so as those names imply, you can just cull these functions with no arguments and you'll get back that data type based on its name.
我们刚开始使用了它,里面有很多的,有用的函数,像,所以,那些名字暗示,你可以挑选这些,没有参数的函数,然后你可以通过它的名字,获取他们的数据类型。
String is actually not a data type in C. It actually is something called a char star and we'll come back to this before long.
字符串在C语言里其实不是一种数据类型,而是一种称为char,*的数据类型,这个知识点我以后会讲到。
Here I'm declaring another data type altogether.
这里我声明另一个数据类型。
I made sure I had the particular type.
我确定了我获得的是这个类型的数据。
Well, unfortunately in C, you have to be ever so specific as to what you wanna put in the variable.
很不幸,在C语言里,给变量赋值之前,你必须搞清楚它的数据类型。
So might have been seen long and that might be correct on some servers, but very, very often the data type called "long" is actually 4 bytes.
你们有可能看到过long,那个在一些服务器上是正确的,但是非常,非常普遍的是,那个叫做“long“的数据类型,只占有4个字节。
Well basically what we're doing is we're giving ourselves the ability to create data types the same way that we have some built-ins, so we have things like int, float, string, these are built-in data types.
就是要赋值我们自己创建,和内置的数据类型,相同的数据类型的能力,我们有一些内置的数据类型,如int,float,string等,如果你考虑下这些数据类型。
Associated with every data type in Python is a type, which identifies the kind of thing it is.
在Python中每种类型都对应着一种数据类型,类型确定了对象的种类。
应用推荐