Hello world开始

一切都从Hello world开始,代码如下:

1 #!/usr/bin/env python    定义程序执行过程中调用的环境  在linux下 直接调用python来解析执行该文件
2 #-*- coding:utf-8 -*-    也可以是  #coding=utf-8 ,作用是设置代码在执行过程中的编码形式,保证可以输出中文,避免中文乱码输出。
3 
4 #输出一个hello world
5 print("hello world")

print 函数时内置函数。在Python终端下可以使用help(print)来查看对应的帮助文档信息。

>>> help(print)
Help on built-in function print in module builtins:

print(...)
    print(value, ..., sep=' ', end='
', 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.

 利用print输出1,2,3,4 以 结尾

print(1,2,3,4,sep=',',end='	')

原文地址:https://www.cnblogs.com/PythonInMyLife/p/6918887.html