python 3.x - Python3 subprocess.check_output output like print -
i have problem process.check_output output.
this happens if use on command line or return it:
subprocess.check_output("echo ls -l", shell=true, universal_newlines=true) 'total 32\n-rw-r--r-- 1 kron kron 63 jul 27 15:15 admin.py\n-rw-r--r-- 1 kron kron 85 jul 27 15:15 apps.py\n-rw-r--r-- 1 kron kron 0 jul 27 15:15 __init__.py\ndrwxr-xr-x 2 kron kron 4096 jul 27 15:15 migrations\n-rw-r--r-- 1 kron kron 387 jul 27 15:49 models.py\ndrwxr-xr-x 2 kron kron 4096 jul 27 16:32 __pycache__\n-rw-r--r-- 1 kron kron 60 jul 27 15:15 tests.py\n-rw-r--r-- 1 kron kron 163 jul 27 16:03 urls.py\n-rw-r--r-- 1 kron kron 358 jul 27 16:32 views.py\n-rw-r--r-- 1 kron kron 0 jul 27 16:39 views.py.save\n'
instead, happens when print() it:
print(subprocess.check_output("ls -l", shell=true, universal_newlines=true)) total 32 -rw-r--r-- 1 kron kron 63 jul 27 15:15 admin.py -rw-r--r-- 1 kron kron 85 jul 27 15:15 apps.py -rw-r--r-- 1 kron kron 0 jul 27 15:15 __init__.py drwxr-xr-x 2 kron kron 4096 jul 27 15:15 migrations -rw-r--r-- 1 kron kron 387 jul 27 15:49 models.py drwxr-xr-x 2 kron kron 4096 jul 27 16:32 __pycache__ -rw-r--r-- 1 kron kron 60 jul 27 15:15 tests.py -rw-r--r-- 1 kron kron 163 jul 27 16:03 urls.py -rw-r--r-- 1 kron kron 358 jul 27 16:32 views.py -rw-r--r-- 1 kron kron 0 jul 27 16:39 views.py.save
i need find way result of second one, meaning need decoded output (with new lines instead of \n), without using print() , save variable.
unfortunately, not find way - if there - it. there way that, possibly without involving external files?
Comments
Post a Comment