python 中的第一个 hello world 程序输出

内容分享4小时前发布
0 0 0

python 中的第一个 hello world 程序输出

程序运行:print(“hello world”)

我使用的是Python程序3.7.0 版本

介绍下print 概念

print 字面意思打印,将文本输出内容打印出来

输入: print(“hello world”)

输出:hello world

python 中的第一个 hello world 程序输出

从源码可以看出为定义的print 为一个函数,有参数:

def print(self, *args, sep=' ', end='
', file=None): # known special case of 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.
    """
    pass

print 做为Python中的使用的一个内定义的函数,可以直接使用

我们可以看下print的参数,

value: 值,可以传递多个值,一般需要打印的

sep : 用于将多个字符进行分割,默认一个空格

end : 用于行尾结束符,默认为回车换行

file : 用于输出的文件,默认为sys.stdout,标准输出, 这里的sys.stdout不过多讲

flush :简单讲将缓存里面的内容立即输出到标准输出流(这里是sys.stdout, 也就是默认的显示器)

© 版权声明

相关文章

暂无评论

none
暂无评论...