python-3.6

Python Drag-and-drop broken

北慕城南 提交于 2019-12-25 14:46:37
问题 I recently installed pywin (I had to change a registry entry to do it, but I changed it back). I also uninstalled Python 2.7, and since then, I can no longer drag and drop files onto my python scripts. I also lost my file associations. I have since uninstalled, reinstalled, run CCleaner on my registry, I've tried setting the default program to C:\Python3\Python.exe, C:\Python\Pythonw.exe, C:\Windows\py.exe, C:\Windows\pyw.exe, I've restarted my computer, but dragging files onto my script

Python: How to save *.dat-files as *.csv-files to new folder

混江龙づ霸主 提交于 2019-12-25 06:36:27
问题 I have a folder with lots of *.dat files (which were created with the program IDL). I am able to take one single file, convert it to a *.csv file and save it in a different (already existing) folder: import idlsave import csv input_file = idlsave.read("C:/Users/RAW/06211714.dat") n = input_file["raw"] with open("C:/Users/CSV/06211714.csv", "w", newline='') as f: writer = csv.writer(f) writer.writerows(n) The line input_file = idlsave.read("C:/Users/RAW/06211714.dat") shows the following

How can I use SetJob in win32print?

心不动则不痛 提交于 2019-12-25 05:19:56
问题 I want to clear or delete print jobs using Python. But how can I get JobID ? win32print.SetJob(hPrinter, JobID , Level , JobInfo , Command) How could I run this code? jobs = [] for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL,None, 1): flags, desc, name, comment = p pHandle = win32print.OpenPrinter(name) print = list(win32print.EnumJobs(pHandle, 0, -1, 1)) jobs.extend(print) SetJob(pHandle, id, 1,JOB_CONTROL_DELETE) #where should i get id from? win32print.ClosePrinter(pHandle)

How to have more than one handler in AWS Lambda Function?

≡放荡痞女 提交于 2019-12-25 02:16:46
问题 I have a very large python file that consists of multiple defined functions. If you're familiar with AWS Lambda, when you create a lambda function, you specify a handler, which is a function in the code that AWS Lambda can invoke when service executes my code, which is represented below in my_handler.py file: def handler_name(event, context): ... return some_value Link Source: https://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html However, as I mentioned

Threads and Tkinter not working together

大憨熊 提交于 2019-12-25 02:15:55
问题 Trying to practice Tkinter, Pyautogui and threading with a simple (or so I thought) auto clicker. It is supposed to open up a menu (check), then a choice of buttons (check), it opens up another window (check), and when you press F7 it starts clicking (not working) This works fine without Tkinter Here is code: from tkinter import * from pyautogui import * from time import * from threading import Thread as th import keyboard root = Tk() key_loop = 1 k = "" root.geometry("150x500") def detect

How do I setup a cron to run specifically with python3?

喜夏-厌秋 提交于 2019-12-24 23:07:13
问题 I'm trying to setup a cron job to run a python script every hour, but it has to be run with python3. I've tried setting up the cron to point to the python 3.6 libraries, but this doesn't seem to work. This is how I've set it up 0 * * * * /usr/local/lib/python3.6/python3 /mnt/dietpi_userdata/python/main.py I suspect it's something simple, but it's beyond my own (googling) skills. 回答1: Are you sure that your python3 path is correct? If you are not using a virtual environment you could try this:

Create more than two turtles and moving them

故事扮演 提交于 2019-12-24 19:46:37
问题 How to make few turtles in a screen and make them move one at once? 回答1: You can use turtle.Turtle() to create many turtles and then you can use it one by one to make small move. Turtles will move almost at the same time. import turtle t1 = turtle.Turtle() t2 = turtle.Turtle() for x in range(36): # first turtle makes small move t1.left(10) t1.forward(10) # second turtle makes small move t2.right(10) t2.forward(10) turtle.done() If you want to move all the time (and do other things at the same

Proper way to de-escape a string with an escaped colon “:” in python 3.6

 ̄綄美尐妖づ 提交于 2019-12-24 19:37:29
问题 I am attempting to write a python script that converts a .properties file (as read by Ant), and converts the result into a dictionary, mapping keys to values. As part of the process (using configparser.RawConfigParser), I discovered that .properties files have their values escaped, and I decided to follow the top result to try and de-escape them (see How do I un-escape a backslash-escaped string in python?). As I am using python 3 (specifically, python 3.6), I use value = value.encode('utf-8'

Variable annotations on a class

隐身守侯 提交于 2019-12-24 18:29:45
问题 I'm trying to build up an object graph in some code where I'm using type hint on class attributes in Python 3.6. Generally this look like: class MyObject: some_variable: float = 1.2 My problem is that I would like to have an attribute that has a type MyObject like this: class MyObject: parent: MyObject = None When I try this I get "NameError: name 'MyObject' is not defined" when I try to do this on the annotation. This seems like an unsupported edge case that cannot currently succeed, since

TensorFlow : optimizer gives nan as ouput

最后都变了- 提交于 2019-12-24 17:07:50
问题 I am running a very simple tensorflow program W = tf.Variable([.3],tf.float32) b = tf.Variable([-.3],tf.float32) x = tf.placeholder(tf.float32) linear_model = W*x + b y = tf.placeholder(tf.float32) squared_error = tf.square(linear_model - y) loss = tf.reduce_sum(squared_error) optimizer = tf.train.GradientDescentOptimizer(0.1) train = optimizer.minimize(loss) init = tf.global_variables_initializer() with tf.Session() as s: file_writer = tf.summary.FileWriter('../../tfLogs/graph',s.graph) s