stdout

Add new line in text file with Windows batch file

余生颓废 提交于 2019-12-03 22:24:50
I have a text file which has more than 200 lines in it, and I just want to add a new line before line 4. I'm using Windows XP. Example text file before input: header 1 header 2 header 3 details 1 details 2 After output: header 1 header 2 header 3 <----- This is new line ----> details 1 details 2 I believe you are using the echo Text >> Example.txt function? If so the answer would be simply adding a "." (Dot) directly after the echo with nothing else there. Example: echo Blah echo Blah 2 echo. #New line is added echo Next Blah khaled You can use: type text1.txt >> combine.txt echo >> combine

Pyqt: 'dynamically' append to qtextedit from function

那年仲夏 提交于 2019-12-03 21:05:47
问题 There is a button in my pyqt gui that when clicked runs a function that does some lengthy math calculations. Inside this function there were a lot of print statements like: print "finished calculating task1 going on to task2" So by using print statements like that i didn't need to have let's say a progressbar for example to indicate program progress. I added a QTextEdit widget in my gui and replaced all print statements in that function with: MyTextEdit.append('message') where MyTextEdit is a

multithreading issue with wx.TextCtrl (or underlying GTK+)

只愿长相守 提交于 2019-12-03 20:27:54
I am developing a GUI to launch an external long-term running background program. This background program can be given input command via stdin and use stdout and stderr to keep printing out output and error messages. I use a wx.TextCtrl object inside the GUI to give input and print output. My current code is as follows, which is mainly inspired by the "how to implemente a shell GUI window" post: wxPython: how to create a bash shell window? However, my following code uses "buffer previous output" approach, i.e., I use a thread to buffer the output. The buffered transaction output could be only

Why is sys.getdefaultencoding() different from sys.stdout.encoding and how does this break Unicode strings?

走远了吗. 提交于 2019-12-03 19:31:04
问题 I spent a few angry hours looking for the problem with Unicode strings that was broken down to something that Python (2.7) hides from me and I still don't understand. First, I tried to use u".." strings consistently in my code, but that resulted in the infamous UnicodeEncodeError . I tried using .encode('utf8') , but that didn't help either. Finally, it turned out I shouldn't use either and it all works out automagically. However, I (here I need to give credit to a friend who helped me) did

How to remove last character put to std::cout?

▼魔方 西西 提交于 2019-12-03 18:40:22
问题 Is it possible on Windows without using WinAPI? 回答1: You may not remove last character. But you can get the similar effect by overwriting the last character. For that, you need to move the console cursor backwards by outputting a '\b' (backspace) character like shown below. #include<iostream> using namespace std; int main() { cout<<"Hi"; cout<<'\b'; //Cursor moves 1 position backwards cout<<" "; //Overwrites letter 'i' with space } So the output would be H 回答2: No. You can't without accessing

how to get stdout into Console.app

余生颓废 提交于 2019-12-03 18:01:11
问题 Earlier, I could read all stdout/stderr data from applications in Console.app. Since a while, this is not the case anymore (NSLog data is still there, though). I'm on 10.8 now. There was an earlier similar question from 2010 which doesn't seem up-to-date anymore. On SU, there is also a similar question which wasn't yet answered. Has that been changed, i.e. stdout is not supposed to be logged anymore? Or is something broken on my system (from the old SU question, it sounded like that might be

What is the difference between writing to STDOUT and a filehandle opened to “/dev/tty”?

南笙酒味 提交于 2019-12-03 17:47:30
问题 What are the differences between this two examples? #!/usr/bin/perl use warnings; use 5.012; my $str = "\x{263a}"; open my $tty, '>:encoding(utf8)', '/dev/tty' or die $!; say $tty $str; close $tty; open $tty, '>:bytes', '/dev/tty' or die $!; say $tty $str; close $tty; # ------------------------------------------------------- binmode STDOUT, ':encoding(utf8)' or die $!; say $str; binmode STDOUT, ':bytes' or die $!; say $str; 回答1: The difference is that you are writing to two distinct and (from

Passing data between Python and C# without writing a file

你说的曾经没有我的故事 提交于 2019-12-03 16:20:42
I would like to pass binary information between Python and C#. I would assume that you can open a standard in/out channel and read and write to that like a file, but there are a lot of moving parts, and I don't know C# too well. I want to do this sort of thing, but without writing a file. # python code with open(DATA_PIPE_FILE_PATH, 'wb') as fid: fid.write(blob) subprocess.Popen(C_SHARP_EXECUTABLE_FILE_PATH) with open(DATA_PIPE_FILE_PATH, 'rb') as fid: 'Do stuff with the data' // C# code static int Main(string[] args){ byte[] binaryData = File.ReadAllBytes(DataPipeFilePath); byte[] outputData;

Prevent Ghostscript from writing errors to standard output

偶尔善良 提交于 2019-12-03 14:44:22
I'm using Ghostscript to rasterize the first page of a PDF file to JPEG. To avoid creating tempfiles, the PDF data is piped into Ghoscripts's stdin and the JPEG is "drained" on stdout. This pipeline works like a charm until GS receives invalid PDF data: Instead of reporting all error messages on stderr as I would have expected, it still writes some of the messages to stdout instead. To reproduce: $ echo "Not a PDF" >test.txt $ /usr/bin/gs -q -sDEVICE=jpeg -dBATCH -dNOPAUSE -dFirstPage=1 -dLastPage=1 \ -r300 -sOutputFile=- - < test.txt 2>/dev/null Error: /undefined in Not Operand stack:

What is the “sys.stdout.write()” equivalent in Ruby?

余生长醉 提交于 2019-12-03 14:38:23
问题 As seen in Python, what is the sys.stdout.write() equivalent in Ruby? 回答1: In Ruby, you can access standard out with $stdout or STDOUT . So you can use the write method like this: $stdout.write 'Hello, World!' or equivalently: STDOUT.write 'Hello, World!' $stdout is a actually a global variable whose default value is STDOUT . You could also use puts , but I think that is more analogous to python's print . 回答2: puts (or print if you don't want a newline ( \n ) automatically appended). 回答3: