[oeasy]python0010_hello_world_unix_c历史迷因
Hello World!
回忆上次内容
- 设置断点的目的是更快地调试
- 调试的目的是去除
bug
- 别害怕
bug
- 一步步地总能找到
bug
- 这就是程序员基本功
- 调试
debug
- 这个bug虫子🕷是有历史渊源的
为啥总是Hello World
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python](https://file.cfanz.cn/uploads/png/2022/11/04/11/BNP10KIO56.png)
奇怪🧐
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_下划线_02](https://file.cfanz.cn/uploads/png/2022/11/04/11/6J9XOU195b.png)
起源
-
linux
操作系统的老祖宗 unix
- 和
unix
对应的编程语言 c
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python_03](https://file.cfanz.cn/uploads/png/2022/11/04/11/HO16Ie6R72.png)
两人
- 1969 年,由于所在
at&t
贝尔实验室的 Multics
项目失败
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_unix_04](https://file.cfanz.cn/uploads/png/2022/11/04/11/b2AA4YFa74.png)
-
Kenneth Thompson
-
Dennis Ritchie
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_unix_05](https://file.cfanz.cn/uploads/png/2022/11/04/11/1DT6714980.png)
游戏
- 这个游戏是
Multics
下的 star travel
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python_06](https://file.cfanz.cn/uploads/png/2022/11/04/11/6aA3V251Ba.png)
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_unix_07](https://file.cfanz.cn/uploads/png/2022/11/04/11/L60aLW861P.png)
-
c
是他们为了开发 unix
而制作的语言 -
unix
是为了能玩 star travel
而制作的系统
hello world!
c
和 unix
只能运行在当时的机器上
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_下划线_08](https://file.cfanz.cn/uploads/png/2022/11/04/11/5Vb518Yf04.png)
- 与他们同在 bell 实验室的
Brian Wilson Kernighan
a.k.a bwk
手稿
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python_09](https://file.cfanz.cn/uploads/png/2022/11/04/11/82127GJ2a4.png)
- 不管是
main
函数,还是printf
函数都有小括号
- 为什么输出字符要用
printf
来当做函数名呢?
print 来历
- 1974 年的手稿😱
- 写在打字机用纸的上面
- 侧面的空洞是向上送纸用的
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_下划线_10](https://file.cfanz.cn/uploads/png/2022/11/04/11/6J7bb9ZI5O.png)
- 所以用
print
来表示输出 -
f
的意思是 format
格式 -
printf
是按格式输出
细节
-
小括号
里面放的是 函数
的 参数
print("hello world")
中
-
函数print
的 参数
是 "hello world"
双引号
引起来意味着hello world
是 字符串
- 输出的内容就是这个字符串
("hello world")
- 小括号和双引号的风格延续到了
python
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_unix_11](https://file.cfanz.cn/uploads/png/2022/11/04/11/6E63e103De.png)
- 最早的入门教学程序都做一个
hello world
- 习惯成自然之后
- 所有的编程语言第一个例子都是
hello world
- 是一种规矩或者文化
成书
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_unix_12](https://file.cfanz.cn/uploads/png/2022/11/04/11/Lfb26CX67e.png)
教材风格
- 1978 年,
Kernighan
和Ritchie
出版了这本书
- 不厚,很薄
- 轻松的语言风格
- 因为
c
的目的就是让人像玩一样编程 - 而不是记忆各种 cpu 汇编指令
- 使得
c
语言成为系统语言的老大 -
python
的源代码就是用纯 c 编的 -
linux
内核 也是用纯 c 编的 - 所以
c
还是非常核心的啊
- 虽说
python
是用纯 c
编写的
- 不过
python
一旦出现之后就可以简化好多东西 - 比如我们的游乐场里面有很多的函数和模块
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python_13](https://file.cfanz.cn/uploads/png/2022/11/04/11/83bXV12f85.png)
内置函数
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python_14](https://file.cfanz.cn/uploads/png/2022/11/04/11/FA45GAc1IA.png)
- dir的意思是directory 文档目录
- 这里列出的是已经导入模块的目录
- 调用这个函数可以知道当前游乐场载入了哪些模块
- 比如
__builtins__
这个模块 - 这
__builtins__
里面又有些什么呢?
dir()
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_unix_15](https://file.cfanz.cn/uploads/jpeg/2022/11/04/11/9ca65K475T.jpeg)
__builtins__
意思是在里面构建好的
- 因为他在默认的这个
__builtins__
模块中
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_下划线_16](https://file.cfanz.cn/uploads/jpeg/2022/11/04/11/55VcN5J16Z.jpeg)
- 如果我想要查询print函数更详细的信息应该如何呢?
help(print)
-
help(print)
- 把函数名作为参数传进去
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python_17](https://file.cfanz.cn/uploads/png/2022/11/04/11/7ADa6685d5.png)
- help(quit)
- help(dir)
- help(help)
- 如果我想要查询__builtins__模块更详细的信息应该如何呢?
help(__builtins__)
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_unix_18](https://file.cfanz.cn/uploads/png/2022/11/04/11/0c02b42046.png)
- 我们可以查询到
__builtins__
模块的帮助文件
- 返回的这些函数和子模块都隶属于
__builtins__
这个模块 - 除了内置的、这些不用引入就可以用的模块之外
导入外部模块
- 这次我们导入的是
__hello__
- 注意hello两边都有两个下划线
import __hello__
- port是港口 来自于海洋文化
- import 是进口 是导入
- export 是出口 是导出
- import 后面接空格
- 然后是被导入的外部模块名称
__hello__
-
hello
左右也是两个下划线
- 导入
__hello__
模块前后游乐场中的模块增加了
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_下划线_19](https://file.cfanz.cn/uploads/jpeg/2022/11/04/11/IIFS26U8cd.jpeg)
- 想要深入了解
__hello__
应该怎么办呢?
什么不会就help什么
help(__hello__)
![图片描述 [oeasy]python0010_hello_world_unix_c历史迷因_python_20](https://file.cfanz.cn/uploads/png/2022/11/04/11/C86I7F6U8Z.png)
总结
- 来自于
unix
和c
- 虽然我们今天有各种先进的学习手段
- 最早的高级语言学习是从最早的那张打字机用纸的手写代码起源的
- 最早输出的是字符串是
"hello world"
- 计算机里面不都是二进制的 0 和 1 吗
- 哪里来的
hello
中的 h
之类的
- 蓝桥->https://www.lanqiao.cn/teacher/3584
- github->https://github.com/overmind1980/oeasy-python-tutorial
- gitee->https://gitee.com/overmind1980/oeasypython
- 视频->https://www.bilibili.com/video/BV1CU4y1Z7gQ 作者:oeasy