zoukankan      html  css  js  c++  java
  • Python3 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

    如上所示:

    python3 中print函数意义为将value值打印到一个数据流中,默认为系统标准输出(sys.stdout)

    print支持一次性打印多个值

    sep=' ' :设置打印字符串之间的字符,也就是隔开方式

     

    end=' ':在字符串结尾添加相应的值,默认为换行符

    file=sys.stdout:输出流指定

    with open('a.txt', 'w') as f:
        print('OK', file=f)

     将‘OK’写入文件

    flush=False:是否清空流

    以前-好记性不如烂笔头 现在-好记性不如烂键盘
  • 相关阅读:
    C# 9.0语法新特性【废弃,自用,无参考价值】
    0兆宽带年费过万,垄断坑企咋破
    筹划建立题目该如何作答?
    去重 sort -u
    大城市治理
    申论话题
    面试 思维
    成语
    人民日报怒批机关事业单位三大怪状
    留痕主义
  • 原文地址:https://www.cnblogs.com/gexbooks/p/14835401.html
Copyright © 2011-2022 走看看