Python 3.6正在打印文字字符\ t和\ n

时间:2019-06-26 19:28:05

标签: python python-3.x

问题:

Python3.6在输出中输出文字字符\ n和\ t

    Output:
    ===============================
    $ python3.6 sample.py
    Running system command: hadoop fs -cat /user/mapr/rajesh/sample.txt
    b'1320352532\t1001\thttp://www.mapr.com/doc\thttp://www.mapr.com\t192.168.10.1\n1320352533\t1002\thttp://www.mapr.com\thttp://www.example.com\t192.168.10.10\n1320352546\t1001\thttp://www.mapr.com\thttp://www.mapr.com/doc\t192.168.10.1\n'
    b'1320352532\t1001\thttp://www.mapr.com/doc\thttp://www.mapr.com\t192.168.10.1\n'
    b'1320352533\t1002\thttp://www.mapr.com\thttp://www.example.com\t192.168.10.10\n'
    b'1320352546\t1001\thttp://www.mapr.com\thttp://www.mapr.com/doc\t192.168.10.1\n'

    Code:
    # To print the sample HDFS file
    cat sample.py

import sys
import subprocess

 cat = subprocess.Popen(["hadoop", "fs", "-cat", "/user/mapr/rajesh/sample.txt"], stdout=subprocess.PIPE)
    for line in cat.stdout:
        print (line)

0 个答案:

没有答案