Python是什么?
Python是个脚本语言。和Perl啦,Basic啦,shell脚本啦一样,都是不用编译就可以执行的。
Python的特点
Python的最大的特点之一就是他是一个动态语言,很灵活,非常适合用于快速开发。同时有着丰富的类库支持,可以做很多的事情。如果经过编译(是的,可以编译),速度和C/C++写的程序效率上是没有区别的。
Hello world?
按学习语言的惯例,先写个helloworld吧。如果你用的Linux的是光盘版,而且开发工具是完全安装的,那么你已经有Python了。如果不是,那么后边会介绍python的安装。
在终端里敲入python:
bash# python
就可以看到python的版本信息和一些简单的介绍。然后是一个提示符">>>"
ok,我们来敲入
>>>welcome = "Hello, Python World!"
>>>welcome
'Hello, Python World!'
按一下Ctrl+D退出Python解释器。成功!不过看起来好像不像是在编程啊。我们来写个程序文件,感觉会好一点。随便用个什么文本编辑器,创建一个文件,就叫welcome.py吧。习惯上python的脚本都是用.py扩展名的。
bash# cat welcome.py
#! /usr/bin/python
welcome = 'Hello, Python World!'
print welcome
bash#chmod +x welcome.py
bash# ./welcome.py
'Hello, Python World!'
[ 本帖最后由 sakulagi 于 2005-12-14 16:21 编辑 ]
sakulagi 回复于:2005-06-01 10:13:59
作为Python新手,希望能把自己学习的过程简单写一下,和新手们共勉
bleem1998 回复于:2005-06-01 13:19:56
有了输出的HelloWorld
我来增加一个输入的HelloWorld
>;>;>; aaa=raw_input('Input something:\n')
Input something:
^oo^
>;>;>; print 'You input:%s' % aaa
You input:^oo^
>;>;>;
蝴蝶永远的梦想 回复于:2005-06-01 17:54:47
sakulagi 大法师,你还没说怎麽编译呢?
既可以以脚本的方式运行,又可以编译成不依赖于解释器(编译器)的可执行application确实不错。
另外,还想问一下sakulagi 大法师,Python网络编程功能、处理图形图像以及数学计算、GUI的功能如何?每一种语言都有他特别强大的一方面,也有相对来说实现起来比较复杂的比较麻烦一些的功能。我想知道Python的主要功能。他有些什么类或者什么类似的东东可以给使用者带来方便?
TY
wolfg 回复于:2005-06-01 23:36:10
鼓励原创!
wolfg 回复于:2005-06-02 00:43:19
引用:原帖由 "Anonymous" 发表: sakulagi 大法师,你还没说怎麽编译呢?
既可以以脚本的方式运行,又可以编译成不依赖于解释器(编译器)的可执行application确实不错。
另外,还想问一下sakulagi 大法师,Python网络编程功能、处理图形图像..........
可以看看Python FAQ上的回答
引用:What is Python good for?
Python is a high-level general-purpose programming language that can be applied to many different classes of problems.
The language comes with a large standard library that covers areas such as string processing (regular expressions, Unicode, calculating differences between files), Internet protocols (HTTP, FTP, SMTP, XML-RPC, POP, IMAP, CGI programming), software engineering (unit testing, logging, profiling, parsing Python code), and operating system interfaces (system calls, filesystems, TCP/IP sockets).
NumPy可以使Python进行精密的数学计算
sakulagi 回复于:2005-06-02 07:45:15
引用:原帖由 "Anonymous" 发表: sakulagi 大法师,你还没说怎麽编译呢?
既可以以脚本的方式运行,又可以编译成不依赖于解释器(编译器)的可执行application确实不错。
另外,还想问一下sakulagi 大法师,Python网络编程功能、处理图形图像.......... 俺也是刚开始学习。正在学习如何编译,呵呵
sakulagi 回复于:2005-06-02 07:45:45
引用:原帖由 "wolfg"]鼓励原创! 发表: 会陆续写的、 :)
wolfg 回复于:2005-06-06 10:22:24
引用:原帖由 "Anonymous" 发表: sakulagi 大法师,你还没说怎麽编译呢?
既可以以脚本的方式运行,又可以编译成不依赖于解释器(编译器)的可执行application确实不错。
另外,还想问一下sakulagi 大法师,Python网络编程功能、处理图形图像..........
py2exe
http://bbs.chinaunix.net/forum/viewtopic.php?t=556861&show_type=new
hspgj 回复于:2005-11-11 15:09:34
引用:原帖由 bleem1998 于 2005-6-1 13:19 发表
有了输出的HelloWorld
我来增加一个输入的HelloWorld
>;>;>; aaa=raw_input('Input something:n')
Input something:
^oo^
>;>;>; print 'You input:%s' % aaa
You input:^oo^
...
没有成功啊
yarco1 回复于:2005-11-12 21:12:59
终于明白了一件事情, 大侠也有cai的时候...
:)
CnOs 回复于:2005-12-10 05:04:08
bash# cat welcome.py
#! /usr/bin/python
welcome = 'Hello, Python World!'
print welcome
bash#chmod +x welcome.py
bash# ./welcome.py
'Hello, Python World!'
上面的语句,怎么那么像Cisco路由器的设置格式的呢?
xiaohu0 回复于:2005-12-12 15:53:54
楼上,把你错误 贴出来!
>>>--可是 py的提示符哦,你是不是把这个也输入了
sakulagi 回复于:2005-12-14 16:22:21
引用:原帖由 bleem1998 于 2005-6-1 13:19 发表
有了输出的HelloWorld
我来增加一个输入的HelloWorld
>;>;>; aaa=raw_input('Input something:\n')
Input something:
^oo^
>;>;>; print 'You input:%s' % aaa
You input:^oo^
...
老fan换论坛引擎的时候出错了。我刚刚编辑了一下帖子
|