mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Updated to include Aleksandar's editorial changes; mostly python to Python
in the comments.
This commit is contained in:
committed by
Jason Shirk (POWERSHELL)
parent
c1ccbc0923
commit
8a6798fb4f
@@ -1,10 +1,10 @@
|
||||
#
|
||||
# Wrap python script in such a way to make it easy to
|
||||
# consume from powershell
|
||||
# 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
|
||||
# picking up the Python script from the same directory
|
||||
#
|
||||
|
||||
& $PSScriptRoot/class1.py | ConvertFrom-JSON
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Demo simple interoperation between PowerShell and Python
|
||||
|
||||
# Basic execution of a python script fragment
|
||||
# Basic execution of a Python script fragment
|
||||
python -c "print('Hi!')"
|
||||
|
||||
# Capture output in a variable
|
||||
@@ -13,7 +13,7 @@ $data
|
||||
# Use in expressions
|
||||
5 + (python -c "print(2 + 3)") + 7
|
||||
|
||||
# Create a python script using a PowerShell here-string, no extension
|
||||
# Create a Python script using a PowerShell here-string, no extension
|
||||
@"
|
||||
#!/usr/bin/python3
|
||||
print('Hi!')
|
||||
@@ -25,7 +25,7 @@ chmod +x hi
|
||||
# Run it - shows that PowerShell really is a shell
|
||||
./hi
|
||||
|
||||
# A mode complex script that outputs JSON
|
||||
# A more complex script that outputs JSON
|
||||
cat class1.py
|
||||
|
||||
# Run the script
|
||||
@@ -49,7 +49,7 @@ cat class1.ps1
|
||||
# And run it, treating the output as structured data.
|
||||
(./class1)[1].buz[1]
|
||||
|
||||
# Finally a PowerShell script with in-line python
|
||||
# Finally a PowerShell script with in-line Python
|
||||
cat inline_python.ps1
|
||||
|
||||
# and run it
|
||||
|
||||
Reference in New Issue
Block a user