Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 1.94 KB

python.md

File metadata and controls

71 lines (48 loc) · 1.94 KB

Python

Python is a programming language that lets you work quickly and integrate systems more effectively.

python.org

Learn

Documentation

Getting started

Training

Step

Installation

Practice

Different ways to execute a command line

from subprocess import call
print('Hello world!')
print(call(['dir'], shell=True))
call(['dotnet', 'My.Dll', 'Myparals'])

from subprocess import Popen, PIPE
cmd = 'blah'
p = Popen('dir', shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
print(stdout)
print(stderr)

import subprocess
print(subprocess.check_output(['dir'], shell=True))
print(subprocess.check_output(['dir'], shell=True).decode('iso-8859-15'))
print(subprocess.check_output(['dir'], shell=True).decode('iso-8859-15').encode('utf-8'))
print(subprocess.check_output(['dir'], shell=True).decode('windows-1255'))

import os
os.chdir('my_previous_path')
print(subprocess.check_output(['dotnet', 'My.Dll', 'Myparals']).decode('ascii'), end='\r\n')

Example:

import os
from subprocess import Popen, PIPE

print "Hello World"

os.chdir('C:\\Users\\xxx\\Projets\\console-dotnet\\src\\ConsoleApp\\bin\\Debug\\netcoreapp2.0')

p = Popen('\"C:\\Program Files\\dotnet\\dotnet.exe" mapp.dll basic-info', shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
print(stdout)
print(stderr)