简体   繁体   中英

Sublime Text build system for input/output in python

I want to use Sublime Text in Ubuntu for python programming and want to write a build system that takes input from a mentioned file and prints output to other mentioned file. I have done same for c++ using this code :

{
    "cmd": ["g++ -std=c++11 ${file} -o ${file_path}/${file_base_name} && ${file_path}/${file_base_name}<${file_path}/inputf.in>${file_path}/outputf.in"],
    "shell" : true
}

Tushar found the solution for himself by modifying the above code like below:

{
    "cmd": ["python ${file}<${file_path}/inputf.in>${file_path}/outputf.in"],
    "shell":true
}

Just in case if somebody is seeking a solution to the same problem in Windows . A few changes to the answer suggested by J.Chomel. will do the work. But first, Save your input and output files in the same folder you are working.

{
"cmd": ["python", "${file}","<inputf.in>outputf.in"],
"shell":true,
"working_dir":"$file_path",
}

This is by far the fastest way to run a python file taking the input from a file and saving the output in a file for me. Seriously. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM