前提
VSCodeで競プロ用のPythonの環境構築をサイトを参考にしながら行っていたのですが、完成し実際にF5キーで動かしてみると「演算子 '<' は、今後の使用のために予約されています。」と表示され、動きませんでした。その後検索すると、<がPowerShellで使えないことが分かったのですが、対処法が分かりません。
具体的には、launch.jsonファイルとtasks.jsonファイルのargsに"<"と"input.txt"(標準入力で使うテキストファイル)が指定され、pythonファイルを実行すると自動的に
~.py < input.txt
となるような仕組みのようなのですが、どう書き直せば動くか教えて下さい。
実現したいこと
プログラムを動かしたい。
発生している問題・エラーメッセージ
発生場所 行:1 文字:294 + ... '51970' '--' 'c:(ユーザー名)\Desktop\work\src\abc258_d.py' < 'input. ... + ~ 演算子 '<' は、今後の使用のために予約されています。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : RedirectionNotSupported
該当のソースコード
サイトの物を持ってきただけなので、https://qiita.com/yoyomion/items/03e8e65fbd8a3d96d9e7
こちらのサイトにすべて載っていますが、一応jsonファイルだけ載せておきます。
launch.json
1{ 2 // IntelliSense を使用して利用可能な属性を学べます。 3 // 既存の属性の説明をホバーして表示します。 4 // 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387 5 "version": "0.2.0", 6 "configurations": [ 7 { 8 "name": "Python: Current File", 9 "type": "python", 10 "request": "launch", 11 "program": "${file}", 12 "console": "integratedTerminal", 13 "justMyCode": true , 14 "args": [ 15 "<", 16 "input.text" 17 ] 18 } 19 ] 20}
tasks.json
1{ 2 // See https://go.microsoft.com/fwlink/?LinkId=733558 3 // for the documentation about the tasks.json format 4 "version": "2.0.0", 5 "tasks": [ 6 { 7 "label": "test_atcorder_sample", 8 "group": { 9 "kind": "build", 10 "isDefault": true 11 }, 12 "type": "shell", 13 "command": "${workspaceFolder}/cptest.bat", 14 "args": [ 15 "${fileBasenameNoExtension}" 16 ], 17 "problemMatcher": [] 18 }, 19 { 20 "label": "test_manual_input", 21 "group": { 22 "kind": "test", 23 "isDefault": true 24 }, 25 "type": "shell", 26 "command": "python", 27 "args": [ 28 "<", 29 "input.text" 30 ] 31 } 32 ] 33}
試したこと
ダメ元でargsを書き換えてみるも動かず。
補足情報(FW/ツールのバージョンなど)
Windows 11
Visual Studio Code 1.71.0
PowerShell 5.1.22000.832


回答1件
あなたの回答
tips
プレビュー