user-input

Command line input in Python

倾然丶 夕夏残阳落幕 提交于 2019-12-03 06:23:34
问题 Is it possible to run first the program then wait for the input of the user in command line. e.g. Run... Process... Input from the user(in command line form)... Process... 回答1: It is not at all clear what the OP meant (even after some back-and-forth in the comments), but here are two answers to possible interpretations of the question: For interactive user input (or piped commands or redirected input) Use raw_input in Python 2.x, and input in Python 3. (These are built in, so you don't need

Suggest answer to user input in bash scripting

回眸只為那壹抹淺笑 提交于 2019-12-03 05:37:12
Here is an example: #!/bin/bash echo -e "Enter IP address: \c" read echo $REPLY But I want to make it easier for the user to answer. I'd like to offer an answer to the user. It should look something like this: Enter your IP: 192.168.0.4 And the user can just press Enter and agree with 192.168.0.4, or can delete some characters (for example delete "4" with one backspace and type 3 instead). How to make such an input? It is possible in bash? bash's read has readline support (Edit: Jonathan Leffler suggests to put the prompt into read as well) #!/bin/bash read -p "Enter IP address: " -e -i 192

How to make a window with buttons in python

本小妞迷上赌 提交于 2019-12-03 04:47:07
How do I create a function that makes a window with two buttons, where each button has a specified string and, if clicked on, returns a specified variable? Similar to @ 3:05 in this video https://www.khanacademy.org/science/computer-science-subject/computer-science/v/writing-a-simple-factorial-program---python-2 (I know it's a tutorial for a very easy beginners program, but it's the only video I could find) but without the text box, and I have more controls over what the 'ok' and 'cancel' buttons do. Do I have to create a window, draw a rect with a string inside of it, and then make a loop

XSS Torture Test - does it exist?

↘锁芯ラ 提交于 2019-12-03 04:43:55
问题 I'm looking to write a html sanitiser, and obviously to test/prove that it works properly, I need a set of XSS examples to pitch against it to see how it performs. Here's a nice example from Coding Horror <img src=""http://www.a.com/a.jpg<script type=text/javascript src="http://1.2.3.4:81/xss.js">" /><<img src=""http://www.a.com/a.jpg</script>" I know there's a Mime Torture Test which comprises of several nested emails with attachments that's used to test Mime decoders (if they can decode it

What is the fastest way to determine a key press and key holding in Win32?

…衆ロ難τιáo~ 提交于 2019-12-03 03:32:50
What is the fastest way to determine a key press and also how to determine if a key is being held? It appears that window messaging is slow. Please provide an example of how to do so, and why it is faster than an alternative. To be clear, this for a real time loop (a simulation) so I am looking for the fastest way to determine if a key has been pressed and also to check to see if it is being held. GetAsyncKeyState() is what you're looking for. It reads the physical state of the keyboard, regardless of the input queue state. If the high-bit is set, then the key was down at the time of the call.

How to upload and read CSV files in React.js?

不羁岁月 提交于 2019-12-03 02:48:25
问题 I would like the user to upload a .csv file, and then have the browser be able to parse the data from that file. I am using ReactJS. How would this work? Thanks. 回答1: Figured it out. A combination of react-file-reader and HTML5's FileReader (see this page). Placed the react-file-reader bit inside of render: <ReactFileReader handleFiles={this.handleFiles} fileTypes={'.csv'}> <button className='btn'>Upload</button> </ReactFileReader> And then this above. handleFiles = files => { var reader =

How to read a binary number as input?

岁酱吖の 提交于 2019-12-03 00:11:29
Is there a way for the user to input a binary number in C or C++? If we write something like int a = 0b1010; std::cout << a << std::endl Then the output comes out to be 10 (when using the appropriate compiler extensions). but when we try to write int n; std::cin >> n; int t = 0bn; It gives us an error so can anyone suggest that how can we directly read binary number as input rather than using string to store input? Alexander Gessler There is a bit of confusion here, let's disentangle it a bit. 0b1010 is an integer literal , a constant, compile-time integer value written in base 2. Likewise,

What's the best approach to get Date/Time input from the user?

孤者浪人 提交于 2019-12-02 21:59:22
This is a wheel that's been re-invented again and again over the years. The Problem: The user needs to input a Date/Time Basic considerations We want to make it as easy as possible for the user to enter the desired date/time Some applications call for historical dates, some applications call for future dates only, some will need to handle both We want to prevent the user from entering jibberish data We want to auto-populate this control as aggressively as possible. We want this control to be as re-usable as possible. Popular solutions include: Text Boxes Combo Boxes Pop-out calendars Server

Default values on empty user input

我们两清 提交于 2019-12-02 21:35:21
Here I have to set the default value if the user will enter the value from the keyboard. Here is the code that user can enter value: input = int(raw_input("Enter the inputs : ")) Here the value will be assigned to a variable input after entering the value and hitting Enter . Is there any method that if we don't enter the value and directly hit the Enter key, the variable will be directly assigned to a default value, say as input = 0.025 ? input = int(raw_input("Enter the inputs : ") or "42") How does it work? If nothing was entered then raw_input returns empty string. Empty string in python is

Javascript - User input through HTML input tag to set a Javascript variable?

拜拜、爱过 提交于 2019-12-02 21:20:04
I want there to be a textbox on my screen(like the one i'm typing in now) that you can type in then click a submit button and it sends whatever you typed in the box to javascript and javascript prints it out.Here is my code This is the part that works. <html> <body> <input type="text" id="userInput"=>give me input</input> <button onclick="test()">Submit</button> <script> function test() { var userInput = document.getElementById("userInput").value; document.write(userInput); } </script> </body> </html> OK so that's nice, but lets say I want input from that textbox and button while I'm already