output

How to remove square brackets from list in Python? [duplicate]

▼魔方 西西 提交于 2019-11-26 12:12:20
问题 This question already has answers here : Print list without brackets in a single row (11 answers) Closed 3 years ago . LIST = [\'Python\',\'problem\',\'whatever\'] print(LIST) When I run this program I get [Python, problem, whatever] Is it possible to remove that square brackets from output? 回答1: You could convert it to a string instead of printing the list directly: print(", ".join(LIST)) If the elements in the list aren't strings, you can convert them to string using either repr (if you

C/C++ printf() before scanf() issue

流过昼夜 提交于 2019-11-26 11:16:15
I'm using Eclipse to code in C/C++ and I'm struggling with what might be something pretty easy. In my code below I use printf() and after scanf() . Althougth printf is written before scanf() the output differs. I was able to find out something about similar issue here . But I wasn't able to solve it. Any ideas? Code: #include <stdio.h> int main() { int myvariable; printf("Enter a number:"); scanf("%d", &myvariable); printf("%d", myvariable); return 0; } Expected output: Enter a number:1 1 Instead I get: 1 Enter a number:1 Your output is being buffered. You have 4 options: explicit flush fflush

How to display progress of scipy.optimize function?

旧城冷巷雨未停 提交于 2019-11-26 11:01:31
问题 I use scipy.optimize to minimize a function of 12 arguments. I started the optimization a while ago and still waiting for results. Is there a way to force scipy.optimize to display its progress (like how much is already done, what are the current best point)? 回答1: As mg007 suggested, some of the scipy.optimize routines allow for a callback function (unfortunately leastsq does not permit this at the moment). Below is an example using the "fmin_bfgs" routine where I use a callback function to

CMake output/build directory

不羁的心 提交于 2019-11-26 10:21:24
问题 I\'m pretty new to CMake, and read a few tutorials on how to use it, and wrote some complicated 50 lines of CMake script in order to make a program for 3 different compilers. This probably concludes all my knowledge in CMake. Now my problem is that I have some source code, whose folder I don\'t want to touch/mess with when I make the program. I want that all CMake and make output files and folders to go into ../Compile/ , so I changed a few variables in my CMake script for that, and it worked

Recreate original PHP array from print_r output

為{幸葍}努か 提交于 2019-11-26 09:42:58
问题 Let\'s say I have this output from some source where I don\'t have access to the original PHP created array: Array ( [products] => Array ( [name] => Arduino Nano Version 3.0 mit ATMEGA328P [id] => 10005 ) [listings] => Array ( [category] => [title] => This is the first line This is the second line [subtitle] => This is the first subtitle This is the second subtitle [price] => 24.95 [quantity] => [stock] => [shipping_method] => Slow and cheap [condition] => New [defects] => ) [table_count] =>

While (( c = getc(file)) != EOF) loop won&#39;t stop executing

核能气质少年 提交于 2019-11-26 09:01:35
I can't figure out why my while loop won't work. The code works fine without it... The purpose of the code is to find a secret message in a bin file. So I got the code to find the letters, but now when I try to get it to loop until the end of the file, it doesn't work. I'm new at this. What am I doing wrong? main(){ FILE* message; int i, start; long int size; char keep[1]; message = fopen("c:\\myFiles\\Message.dat", "rb"); if(message == NULL){ printf("There was a problem reading the file. \n"); exit(-1); } //the first 4 bytes contain an int that tells how many subsequent bytes you can throw

Create Java console inside a GUI panel

你说的曾经没有我的故事 提交于 2019-11-26 06:55:38
How can I create an instance of the Java console inside of a GUI panel? Lawrence Dol Here's a functioning class. You can install an instance of this into the system out and err using: PrintStream con=new PrintStream(new TextAreaOutputStream(...)); System.setOut(con); System.setErr(con); Updated 2014-02-19 : To use EventQueue.invokeLater() to avoid GUI threading issues which can crop up very rarely with the original. Updated 2014-02-27 : Better implementation Updated 2014-03-25 : Correct recording & deletion of lines in text area to be within the run() method to avoid race-condition between

How can I suppress column header output for a single SQL statement?

穿精又带淫゛_ 提交于 2019-11-26 06:29:50
问题 I\'m executing some SQL statements in batch (using the mysql command-line binary). I want one of my several SELECT statements to not print the column headers, just the selected records. Is this possible? 回答1: Invoke mysql with the -N (the alias for -N is --skip-column-names ) option: mysql -N ... use testdb; select * from names; +------+-------+ | 1 | pete | | 2 | john | | 3 | mike | +------+-------+ 3 rows in set (0.00 sec) Credit to ErichBSchulz for pointing out the -N alias. To remove the

How to use python numpy.savetxt to write strings and float number to an ASCII file?

六月ゝ 毕业季﹏ 提交于 2019-11-26 06:29:05
问题 I have a set of lists that contain both strings and float numbers, such as: import numpy as num NAMES = num.array([\'NAME_1\', \'NAME_2\', \'NAME_3\']) FLOATS = num.array([ 0.5 , 0.2 , 0.3 ]) DAT = num.column_stack((NAMES, FLOATS)) I want to stack these two lists together and write them to a text file in the form of columns; therefore, I want to use numpy.savetxt (if possible) to do this. num.savetxt(\'test.txt\', DAT, delimiter=\" \") When I do this, I get the following error: >>> num

PHP - while loop (!feof()) isn&#39;t outputting/showing everything

♀尐吖头ヾ 提交于 2019-11-26 03:45:58
问题 I am trying to read (and echo) everything of a .txt-File. This is my code: $handle = @fopen(\"item_sets.txt\", \"r\"); while (!feof($handle)) { $buffer = fgets($handle, 4096); $trimmed = trim($buffer); echo $trimmed; } This is my \"item_sets.txt\": http://pastebin.com/sxapZGuW But it doesn\'t echo everything (and changing how much it shows depending on if and how many characters i echo after it). var_dump() shows me that the last string is never finished printing out. That looks like this: \"