반응형
powershell(ubuntu version)에서 python 호출하기
1. class1.py
#!/usr/bin/python3 import json # Define a class with a method that returns JSON class returnsjson: def method1(this): return json.dumps(['foo', { 'bar': ('baz', None, 1.0, 2), 'buz': ('foo1', 'foo2', 'foo3') }, 'alpha', 1,2,3]) c = returnsjson() print (c.method1())
2. class1.ps1
# # Wrap Python script in such a way to make it easy to # consume from PowerShell # # The variable $PSScriptRoot points to the directory # from which the script was executed. This allows # picking up the Python script from the same directory # & $PSScriptRoot/class1.py | ConvertFrom-JSON
3. 실행&결과
반응형
'Python' 카테고리의 다른 글
command pattern (0) | 2016.11.22 |
---|---|
whitehat cft 문제 (0) | 2016.10.10 |
tuple (0) | 2016.07.21 |
python list (0) | 2016.07.21 |
디폴트 인자 (0) | 2016.07.21 |