user-input

Django: Problem with Separating the Two User Names

耗尽温柔 提交于 2019-12-13 02:47:57
问题 I am learning Django by building an application, called TravelBuddies. It will allow travelers to plan their trip and keep associated travel items (such as bookings, tickets, copy of passport, insurance information, etc), as well as create alerts for daily activities. The application will also able to update local information such as weather or daily news to the traveler. Travelers can also share the travel information with someone or have someone to collaborate with them to plan for the trip

How to detect keypress

Deadly 提交于 2019-12-13 01:30:03
问题 I am using java and trying to write a simple sudo mouse recorder that will store the mouse position when the space key is pressed. The only key I need to detect is the space key (Although if another key is easier, that will work). I need the whole mouse recorder to be written in java, but it is OK if the function for the keypress is in another language. And I will be runing this in Windows 7. What is the simplest way to do what has been described? All of the methods I have found require at

Ruby on Rails: Using user input for calculations on the same page

拜拜、爱过 提交于 2019-12-13 01:28:12
问题 So, I'm having issues with what I think is a really simple problem. I don't know how to access user input...or perhaps I don't know how to declare a temporary variable in rails. Anyway, what is the most straight forward way of accomplishing this: <div> Enter Group Size: <%= number_field_tag(:group_size)%> Select Study Site: <%= number_field_tag(:site) %> </div> <% if :site > 4 %> Hello! <% else %> Nope! <% end %> I suppose I'll need javascript to actually make it work, but for now I just need

Assigning the output of cin to variables

こ雲淡風輕ζ 提交于 2019-12-13 00:25:05
问题 I'm trying to learn how to use cin and getline to write a paper grading program that I can use at school. It's kind of a tricky project for a beginner but it lets me know what I need to learn and this is the first thing I need to do. int main() { string grader; int x; cout << "Who will I be assisting today? "; getline (cin, grader); cout << "Hello " << grader << ".\n"; cout << "How manny questions are on the test you will be grading? "; getline (cin, x); cout << "this is a " << x << "question

Boost SolR results using users behavior

拈花ヽ惹草 提交于 2019-12-13 00:10:44
问题 I would like SolR to be able to "learn" from my website users' choices. By that i mean that i know which product the user click after he performed a search. So i collected a list of [term searched => number of clicks] for each product indexed in SolR. But i can't figure how to have a boost that depends on the user input. Is it possible to index some key/value pairs for a document and retrieve the value with a function usable in the boost parameter ? I'm not sure to be clear, so i'll add a

How to accept input without the need to press enter Python 3 [duplicate]

空扰寡人 提交于 2019-12-12 19:23:16
问题 This question already has answers here : raw_input in python without pressing enter (7 answers) Closed 5 years ago . i'm wondering how to accept input without the need to press enter. i searched online, and i get something regarding raw_input, but i think that became obsolete after the arrival of python 3.0. sometimes, i run a while loop on a whole program since i want to ask the user: continue? (y/n): for instance consider the code: import random d = input('Toss coin? (y/n): ') while d != 'n

Windows Service - Find out when the last user action was [closed]

删除回忆录丶 提交于 2019-12-12 16:16:25
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I wrote an application in Java and it's purpose is to log the last time any user action has taken place. When running this application logged in it works

Type safety of input.nextLine?

瘦欲@ 提交于 2019-12-12 16:10:07
问题 Would there ever be a case where an exception could be thrown by assigning the value of input.nextLine() to a String variable with the Scanner ? Like if you put String foo = input.nextInt(); You would get an InputMismatchException . So what I'm wondering is if there's any possible way to get an exception from: String foo = input.nextLine(); It might be a dumb question but I need to be absolutely sure. Thanks in advance! 回答1: The answer in the docs: Throws: NoSuchElementException - if no line

find closest point from users coordinates

◇◆丶佛笑我妖孽 提交于 2019-12-12 13:09:42
问题 I would like to know how to use find the closes point using coordinates. i am using a Hashmap which holds coordinates and strings. i have allowed the user to input an x and y axis and store them as int a and int b but i don't know where to go from there. thanks for looking import java.util.HashMap; import java.util.Scanner; public class Coordinate { static class Coords { int x; int y; public boolean equals(Object o) { Coords c = (Coords) o; return c.x == x && c.y == y; } public Coords(int x,

Most Pythonic way to do input validation [duplicate]

霸气de小男生 提交于 2019-12-12 10:45:14
问题 This question already has answers here : Asking the user for input until they give a valid response (18 answers) Closed 4 years ago . What is the most "correct", Pythonic way to do user input validation in Python? I've been using the following: while True: stuff = input("Please enter foo: ") try: some_test(stuff) print("Thanks.") break except SomeException: print("Invalid input.") Which is nice and readable, I suppose, but I can't help wondering if there isn't some built-in function or