python-3.4

Writing a pandas dataframe to a word document table via pywin32

大兔子大兔子 提交于 2019-12-09 23:53:58
问题 I am currently working on a script that needs to write to a .docx file for presentation purposes. I use pandas to handle all my data calculations in the script. I am looking to write a pandas dataframe into a table at a bookmark in a word.docx file using PyWIN32. The dataframe consists of floats. The psuedo code is something like this. frame = DataFrame(np.arange(28).reshape((4,7)), columns=['Text1',...'Text7']) With pywin32 imported... wordApp = win32.gencache.EnsureDispatch('Word

Please explain “Task was destroyed but it is pending!”

主宰稳场 提交于 2019-12-09 08:18:39
问题 Python 3.4.2 I am learning asyncio and I use it to continously listen IPC bus, while gbulb listens to the dbus. Some side notes: So I created a function listen_to_ipc_channel_layer that continously listens for incoming messages on the IPC channel and passes the message to a message_handler . I am also listening to SIGTERM and SIGINT. So when I send a SIGTERM to the python process running the code you find at the bottom, the script should terminate gracefully. The problem … I am having is the

Discovering keys using h5py in python3

本秂侑毒 提交于 2019-12-09 07:59:21
问题 In python2.7 , I can analyze an hdf5 files keys use $ python >>> import h5py >>> f = h5py.File('example.h5', 'r') >>> f.keys() [u'some_key'] However, in python3.4 , I get something different: $ python3 -q >>> import h5py >>> f = h5py.File('example.h5', 'r') >>> f.keys() KeysViewWithLock(<HDF5 file "example.h5" (mode r)>) What is KeysViewWithLock , and how can I examine my HDF5 keys in Python3? 回答1: From h5py's website (http://docs.h5py.org/en/latest/high/group.html#dict-interface-and-links):

Python for loop decrementing index

谁都会走 提交于 2019-12-09 00:52:19
问题 So I wrote a for loop like this: for i in range(size): if(.....) .... i-=1 else: .... I try to decrease the index by 1 if it is inside the if statement, but apparently I can't do that. Is there any other way that I can decrease i in a for loop? 回答1: I would like to go over the range() function yet again through the documentation as provided here: Python 3.4.1 Documentation for range(start, stop[, step]) As shown in the documentation above, you may enter three parameters for the range function

pyautogui.locateCenterOnScreen() returns None instead of coordinates

谁说我不能喝 提交于 2019-12-08 15:48:51
问题 import pyautogui print (pyautogui.locateCenterOnScreen("C:\Users\Venkatesh_J\PycharmProjects\mouse_event\mouse_event.png")) Instead of returning coordinates, it returns None . 回答1: Seems like it couldn't find anything matching your image on the screen. locateCenterOnScreen(image, grayscale=False) - Returns (x, y) coordinates of the center of the first found instance of the image on the screen. Returns None if not found on the screen. 回答2: My problem is Solved when i took screenshot by

Sending an email, via python, from one outlook account to another

只谈情不闲聊 提交于 2019-12-08 11:46:27
问题 I'm writing a program to help the school's Biology Department and it involves sending an email. I've gathered all of the variables I need for the content of the message, it's just the actual sending of the email that's causing some issues. I've looked around and realized that I was using code that sent to gmail, whereas the servers at school use Outlook 2010. Once I remembered that, I looked around for some python code that sent emails, but so far nothing has worked. It all seems very

Python open() requires full path

不想你离开。 提交于 2019-12-08 11:37:47
问题 I am writing a script to read a csv file. The csv file and script lies in the same directory. But when I tried to open the file it gives me FileNotFoundError: [Errno 2] No such file or directory: 'zipcodes.csv' . The code I used to read the file is with open('zipcodes.csv', 'r') as zipcode_file: reader = csv.DictReader(zipcode_file) If I give the full path to the file, it will work. Why open() requires full path of the file ? 回答1: From the documentation: open(file, mode='r', buffering=-1,

Module being imported from another Python install

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 10:48:43
问题 I'm running multiple installs of Python on Windows Server 2012. I can probably find a way to work around this, but I'm curious as to what is going on. I'm wary about radically changing the installs in case I break other people's Python scheduled tasks that I may not be aware of. (All the code boxes below are PowerShell). PS C:\> C:\Python34\Scripts\pip.exe list jdcal (1.0) pip (7.1.2) setuptools (12.0.5) virtualenv (13.1.2) Although this Python 3.4 install doesn't have Django installed, it

How to send unsent logs to python logging server when it comes back online?

天涯浪子 提交于 2019-12-08 09:03:36
问题 I have successfully created a central python logging server on one computer and can log to it from multiple RPis. However when the logging server goes down the logs are lost. Is there a way to store the logs (in a persistent form) until the logging server becomes available again? I have looked at a few programs such as graylog, sentry and logstash but couldn't see any option to do this. Any help would be much appreciated. 回答1: I've come up with a custom socket handler, which buffers unsent

Pip with Python 2.7 and 3.4 on Windows Machine

五迷三道 提交于 2019-12-08 08:15:58
问题 I have both Python 2.7 and 3.4 on my Windows machine. I have pip, pip2, and pip3. Pip2 is 2.7 while the others are 3.4 when running pip(,2,3) -V However, pip -V , pip2 -V and pip3 -V All show the same thing about pips location and all but pip2 show that it's for Python3.4. For all three the location they show for pip is C:\Python27\site-packages. Which is fine for pip2, but for pip3, and pip(if posssible, not 100% necessary), they should show the location as C:\Python34 instead. Not sure why