raw-input

Python code to determine if TLD exists, prompt again if not?

房东的猫 提交于 2019-12-24 10:55:34
问题 This is an additional question in regards to this post: Python raw_input with forced TLD? I have a check in place to see if a string ends with a TLD, TLD = ('.com', '.info', '.org', '.net') if raw_input("Please enter a hostname").endswith(TLD): # blah blah But I am attempting to store the raw_input in to a variable. Would the proper coding practice be to do something such as: TLD = ('.com', '.info', '.org', '.net') hostName = raw_input(":").lower() <<piece of code that determines if hostName

Python raw_input use TAB instead of ENTER?

我是研究僧i 提交于 2019-12-24 01:53:02
问题 I've made this little script to handle a CSV export from my store's point of sale. It takes a list of barcodes entered by our barcode scanner. Then looks up those items in a list to quickly check our physical inventory from what the point of sale claims we have. It works... what I'm curious is if I can change raw_input from it's default use of ENTER and replace it with TAB? My barcode scanner is programmed to use a TAB after it scans a barcode (as our POS demands that it does), would make it

Python : raw_input and print in a thread

落爺英雄遲暮 提交于 2019-12-23 23:05:43
问题 I have a thread which can print some text on the console and the main program have a raw_input to control the thread. My problem is when I'm writing and the thread too I get something like this: -->whatiwWHATTHETHREADWRITErite but I would like to get some thing like this WHATTHETHREADWRITE -->whatiwrite Thank you! 回答1: You have to syncronize your input with the thread output preventing them from happening at the same time. You can modify the main loop like: lock = threading.lock() while 1:

Multiple Raw Input Window Sinks

僤鯓⒐⒋嵵緔 提交于 2019-12-23 11:47:46
问题 I have a message-only window (ATL::CWindowImpl) that registers itself for raw input using the RIDEV_INPUTSINK flag, meaning it gets all input regardless of whether the window is the foreground window. This works great when there's only one instance of that window. However, when I create more than 1 instance of my window, only one receives the WM_INPUT messages (I'm currently creating two, and only the second one to be created gets the messages). RegisterRawInputDevices (using RIDEV_INPUTSINK

Inputing floats, integers, or equations in raw_input to define a variable

雨燕双飞 提交于 2019-12-23 02:38:49
问题 I've written this program so solve two equations based on values defined by the user. The constants kx and ky, I've defined as floats. For the range - variables start and end - I would like the user to either enter a number, or something like 6 * np.pi (6Pi). As it is now, I get the following error. How can I define this variable to allow users to enter multiple types of inputs? Thanks! Traceback (most recent call last): File "lab1_2.py", line 11, in <module> x = np.linspace(start, end, 256,

Python: How to quit CLI when stuck in blocking raw_input?

三世轮回 提交于 2019-12-22 13:53:22
问题 I have a GUI program which should also be controllable via CLI (for monitoring). The CLI is implemented in a while loop using raw_input. If I quit the program via a GUI close button, it hangs in raw_input and does not quit until it gets an input. How can I immediately abort raw_input without entering an input? I run it on WinXP but I want it to be platform independent, it should also work within Eclipse since it is a developer tool. Python version is 2.6. I searched stackoverflow for hours

How to print over raw_input's line in Python?

感情迁移 提交于 2019-12-21 19:52:25
问题 Usually, when raw_input asks you to type something in and press Return, feedback is printed on a new line. How can I print over the prompt's line? Could a CR work in this case? Demo: prompt = "Question: " answer = raw_input(prompt) print answer print("Correct!") Simulated output after typing an answer and pressing Return: >> Question: my answer >> Correct! Desired output: >> Correct! 回答1: Use blessings: from blessings import Terminal term = Terminal() raw_input("Question: ") print(term.move

Low level keyboard hook & keystrokes from rawinput

╄→гoц情女王★ 提交于 2019-12-21 02:27:34
问题 Currently, I'm making a program that intercept keystrokes from a specific keyboard (filtered using its HID). So to know which keystrokes have been sent by a specific device, I used the RawInput technic, inspired by this great tutorial: http://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard Now, it works great: I can get a keystroke and know which keyboard have generated it. The difficult part of my project is to intercept and block keystrokes from this

What is the proper way to take a directory path as user input?

被刻印的时光 ゝ 提交于 2019-12-18 13:08:23
问题 Below is a snippet of code I am trying to use to take a directory path as "raw input" from the user. I receive the following error after the input is taken from the user: Traceback (most recent call last): File "C:\Users\larece.johnson\Desktop\Python Programs\Hello World 2", line 14, in <module> f = open(str,"r+") #I open the text file here which the user gave me IOError: [Errno 2] No such file or directory: 'C:/Users/larece.johnson/Desktop/Python Programs/BostonLog.log.2014-04-01' Ignoring

Hiding raw_input() password input

假如想象 提交于 2019-12-18 03:51:35
问题 I want to hide my password but I don't know how. I have seen show="*" and also getpass but I don't know how to place them into this code. I'm using Python 2.7.3 and coding on a Raspberry Pi. ans = True while ans: print(""" ------------- | 1. Shutdown | | 2. Items | ------------- """) ans=raw_input(""" Please Enter A Number: """) if ans == "1": exit() elif ans == "2": pa=raw_input(""" Please Enter Password: """) if pa == "zombiekiller": print(""" ---------------- | 1. Pi password | | 2.