美文网首页
python标准输入输出2

python标准输入输出2

作者: Babyzpj | 来源:发表于2017-09-25 11:45 被阅读0次

参考:http://blog.csdn.net/zheng_integer/article/details/54986762

1、raw_input()和input()的区别:

     Python 2里面读取输入的函数是raw_input(), Python 3的是input()

2、sys.stdin.readline()和sys.stdin.read()的区别

        sys.stdin.readline() 仅仅接受一行的全部输入

        sys.stdin.read()可以接受多行的标准输入

3sys.stdin.read()和raw_input()接受和返回的都是原始字符串

raw_input():遇到输入enter停止输入,返回。raw_input( )获取输入时返回的结果是不包含末尾的换行符'\n'的

sys.stdin.read():读取数据 ctrl+d是结束输入 ,enter是换行。故可以接受多行输入

sys.stdin.readline( ):会将标准输入全部获取,包括末尾的'\n',因此用len计算长度时是把换行符'\n'算进去了的。会遇到enter返回

相关文章

  • Shell | 标准输入输出重定向

    一、Linux 标准输入输出 二、标准输入输出重定向 1. 标准输入输出重定向是什么? 2. 标准输入输出重定向的...

  • 2018-11-12day10-python2和python3

    python2和python3的区别 一、输入输出语句变成了输入输出函数 python2 --- print "...

  • python标准输入输出2

    参考:http://blog.csdn.net/zheng_integer/article/details/549...

  • python3 c++ 和 java

    基本语法 长度 python c++ java 标准化输入&输出 python c++在C++中,标准的输入输出是...

  • python标准输入输出

    python2 和python3输入输出的差别: https://www.runoob.com/python/py...

  • c++代码入门2

    c++ 中的 标准输入输出 2.c++ 中的标准输入输出(字符类型) 3.c++ 中的无限输入(cin,cout)...

  • Python(二)基本概念

    一、输入输出 (1)输出 输出:将数据打印到标准输出设备(屏幕),在python 2.7中使用print()函数,...

  • c/c++刷题常用

    头文件stdio.hc语言的标准输入输出,常用printf;scanfiostreamc++语言的标准输入输出,重...

  • Windows 批处理脚本指南: 变量

    OverviewPart 1 – 开始Part 2 – 变量Part 3 – 返回值Part 4 – 标准输入输出...

  • python基础●基础知识

    此篇文章主要讲解python的基础知识,如输入输出,运算符等 python基础●输出 python 2的输出 :p...

网友评论

      本文标题:python标准输入输出2

      本文链接:https://www.haomeiwen.com/subject/ozvrextx.html