python入门

来源:互联网 发布:大数据价值密度 编辑:程序博客网 时间:2024/06/05 10:32

1、安装
在官网上下载即可:http://www.python.org/
2、hello world
安装之后,按照网上的教程,发现失败了。

>>> print "hello world!"  File "<stdin>", line 1    print "hello world!"                       ^SyntaxError: Missing parentheses in call to 'print'

研究之后,网上的教程多是针对python3.0之前的版本,而python3.0以上的版本需要加括号,也就是说由print语句演变成print()函数。
这也提醒我们python3.0之后的版本语法和之前的有很大的不同,详见:http://blog.csdn.net/mountainest/article/details/77140645。

>>> print("hello world!")hello world!>>> print('hello world!')hello world!

3、帮助命令
help(keywords)或者keywords help

>>> help(print)Help on built-in function print in module builtins:print(...)    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)    Prints the values to a stream, or to sys.stdout by default.    Optional keyword arguments:    file:  a file-like object (stream); defaults to the current sys.stdout.    sep:   string inserted between values, default a space.    end:   string appended after the last value, default a newline.    flush: whether to forcibly flush the stream.
原创粉丝点击