首页WIN11问题[oeasy]python0010_hello_world_unix_c历史迷因

[oeasy]python0010_hello_world_unix_c历史迷因

时间2022-12-12 00:45:08发布分享专员分类WIN11问题浏览94

Hello World!

回忆上次内容

directory exists 我们这次设置了断点

设置断点的目的是更快地调试

调试的目的是去除 bug

别害怕 bug

一步步地总能找到 bug

这就是程序员基本功

调试 debug

这个bug虫子🕷是有历史渊源的

编程也是有历史迷因的

为什么写程序都从hello world开始directory exists ?🤔

为啥总是Hello World

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

奇怪🧐

不论学习什么编程语言

总是从Hello World开始

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

为什么呢directory exists ?🤔

起源

这一切都要从头说起

linux 操作系统的老祖宗 unix

和 unix 对应的编程语言 c

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

那是一切开始的地方

两人

1969 年directory exists ,由于所在 at&t 贝尔实验室的 Multics 项目失败

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

无所事事的两人

Kenneth Thompson

Dennis Ritchie

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

游戏

希望能在 PDP 机器上继续玩一个游戏

这个游戏是 Multics 下的 star travel

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

为directory exists 了玩这个游戏

directory exists 他们想要做一个操作系统 unix

为directory exists 了制作操作系统

directory exists 他们创造了 c 语言的编译器

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

当时

c 是directory exists 他们为了开发 unix 而制作的语言

unix 是为directory exists 了能玩 star travel 而制作的系统

hello worlddirectory exists !

c 和 unix 只能运行在当时的机器上

没有文档

没有书籍

甚至没有人知道

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

与directory exists 他们同在 bell 实验室的 Brian Wilson Kernighan a.k.a bwk

开始写 c 语言的类似于文档说明书的东西

手稿

主体的函数叫做 main函数

里面输出函数叫做 printf函数

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

不管是main函数directory exists ,还是printf函数都有小括号

小括号 从那个时候就和函数相关

为什么输出字符要用printf来当做函数名呢?

print 来历

1974 年的手稿😱

写在打字机用纸的上面

侧面的空洞是向上送纸用的

是不是很像胶片

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

打字机就是当时的显示器

所以用 print 来表示输出

f 的意思是 format 格式

printf 是按格式输出

细节

printf函数 后面有 小括号

小括号 里面放的是 函数 的 参数

print("hello world") 中

函数print 的 参数 是 "hello world"

双引号 引起来意味着hello world 是 字符串

输出的内容就是这个字符串 ("hello world")

小括号和双引号的风格延续到directory exists 了 python

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

从 c语言 开始

最早的入门教学程序都做一个hello world

习惯成自然之后

所有的编程语言第一个例子都是hello world

是一种规矩或者文化

这个梗一直流传到今天

除directory exists 了时间因素之外

还有一个重要的原因

成书

有directory exists 了教材就有更多人学

有更多人学就有更多人参与其中

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

正反馈在逐渐成型

教材风格

1978 年directory exists ,Kernighan和Ritchie出版了这本书

不厚directory exists ,很薄

轻松的语言风格

因为 c 的目的就是让人像玩一样编程

而不是记忆各种 cpu 汇编指令

蓬勃发展的计算机技术

使得 c 语言成为系统语言的老大

python 的源代码就是用纯 c 编的

linux 内核 也是用纯 c 编的

所以c还是非常核心的啊

虽说 python 是用纯 c 编写的

不过 python 一旦出现之后就可以简化好多东西

比如directory exists 我们的游乐场里面有很多的函数和模块

我们为什么能认识printdirectory exists ?

而不认识prontdirectory exists ?

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

内置函数

dir()

可以看到游乐场上来就自带的模块

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

比如 dir() 这个函数

dir的意思是directory 文档目录

这里列出的是已经导入模块的目录

调用这个函数可以知道当前游乐场载入directory exists 了哪些模块

比如 __builtins__ 这个模块

这 __builtins__ 里面又有些什么呢directory exists ?

dir()

dir(__builtins__)

注意前后都是两个下划线

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

__builtins__ 意思是在里面构建好的

这里面有好多内置的函数

包括directory exists 我们熟悉的

exit()

print()

dir()

help()

为什么print直接就能用

因为directory exists 他在默认的这个__builtins__模块中

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

如果我想要查询print函数更详细的信息应该如何呢directory exists ?

help(print)

什么不会就help什么

help(print)

把函数名作为参数传进去

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

类似的还可以查询

help(quit)

help(dir)

help(help)

如果我想要查询__builtins__模块更详细的信息应该如何呢directory exists ?

help(__builtins__)

help(__builtins__)

注意内置模块builtins左右各有两个下划线

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

directory exists 我们可以查询到__builtins__模块的帮助文件

返回的这些函数和子模块都隶属于 __builtins__ 这个模块

除directory exists 了内置的、这些不用引入就可以用的模块之外

还可以引入外部模块

导入外部模块

就像directory exists 我们上次导入ast一样

这次directory exists 我们导入的是__hello__

注意hello两边都有两个下划线

import __hello__

import

port是港口 来自于海洋文化

import 是进口 是导入

export 是出口 是导出

import 后面接空格

然后是被导入的外部模块名称 __hello__

hello左右也是两个下划线

把__hello__模块导入到游乐场

可以输出经典的一句话

注意directory exists !

导入 __hello__ 模块前后游乐场中的模块增加directory exists 了

正在上传…重新上传取消

[oeasy]python0010_hello_world_unix_c历史迷因

想要深入了解 __hello__ 应该怎么办呢directory exists ?

什么不会就help什么

help(__hello__)

[oeasy]python0010_hello_world_unix_c历史迷因

编辑

[oeasy]python0010_hello_world_unix_c历史迷因

总结

hello world 不是从来就有的

来自于unix和c

虽然directory exists 我们今天有各种先进的学习手段

最早的高级语言学习是从最早的那张打字机用纸的手写代码起源的

输出用的函数名是 print 打印

也是从那个时候来的

最早输出的是字符串是 "hello world"

也是从那个时候来的

这就成directory exists 了一个迷因

等等directory exists !

计算机里面不都是二进制的 0 和 1 吗

哪里来的hello 中的 h 之类的

蓝桥->

github->

gitee->

视频->

爱资源吧版权声明:以上文中内容来自网络,如有侵权请联系删除,谢谢。

pythonoeasyhelloworld史迷因python史迷因directory exists
Python实例|Python批量创建多个空白的Excel文件(附源码+视频) 联想小新潮5000笔记本U盘重装win10系统教程