somewheve:
https://docs.python.org/3/using/cmdline.html
これは、オプションのマニュアルです。しかし、それは私に任意の有用なメッセージを提供していません。
私はこの方法でコードを実行したいです
python -c "def hello():\n print('hello world')"
エラーメッセージ
PS C:\Users\Administrator> python -c "def hello():\n print('hello world')"
File "<string>", line 1
def hello():\n print('hello world')
^
SyntaxError: unexpected character after line continuation character
それは窓をLinux上で動作しますが、ありません。
あなたは完全な固定コマンドを与えることを願って~~~
ヒープオーバーフロー:
バックスラッシュの代わりにバッククォート試してみてください。
エラー:
PS C:\Users\me> python -c "def hello():\n print('hello world')"
File "<string>", line 1
def hello():\n print('hello world')
^
SyntaxError: unexpected character after line continuation character
PS C:\Users\me>
OK:
PS C:\Users\me> python -c "def hello():`n print('hello world')"
PS C:\Users\me>
有用:
PS C:\Users\me> python -c "def hello():`n print('hello world')`nhello()"
hello world
PS C:\Users\me>
ちょうどそれを見るためにエコー:
PS C:\Users\me> echo "def hello():`n print('hello world')`nhello()"
def hello():
print('hello world')
hello()
PS C:\Users\me>
参照してくださいPowerShellを使用し新ライン:パワーヒントを