python-2.7

Random TimeoutException even after using ui.WebDriverWait() chrome selenium python

梦想与她 提交于 2021-02-11 10:47:31
问题 Random timeout exception for the code below not sure whats the best approach to address these issues, and this timeout not happen all time, and also it does find elements sometime or all time we appreciate your comments and suggestions and apparently explicit wait is not handling until the elements gets loaded into the browser application or elements are getting different interval in every single time when new page gets loaded """ """ import platform , logging import os,re from time import

How to move a zip file to a new destination and then open it in python 3

白昼怎懂夜的黑 提交于 2021-02-11 08:49:54
问题 How to move a zip file to a new destination and then open it in python 3. I have made following code, but it seems it does not work for zip file. import os source = "C:/Users/sa/Desktop/Pic_ - Im.zip" destination = "C:/Users/sa/Pictures/pic" os.rename(source, destination) 回答1: This will move the zip from one location to another and then extract its contents to a directory of your choosing ( other_dir , in this instance) import shutil import zipfile from contextlib import closing def _unzip

changing the format of timestamp in python

本秂侑毒 提交于 2021-02-11 08:23:31
问题 I am trying to change the timestamp from one format to another. I tried some approaches but i am not able to succeed. This is my timestamp 151005-12:07:34.917928 I would like to change it to a format like this 2015-10-05 12:07:34:917928 Thanks in Advance 回答1: Here's one way using regular expressions: import re e = '(\d{2})(\d{2})(\d{2})-(\d{2}:\d{2}:\d{2})\.(\d+)' s = '151005-12:07:34.917928' print('20{}-{}-{} {}:{}'.format(*re.search(e, s).groups())) 2015-10-05 12:07:34:917928 Here's another

changing the format of timestamp in python

本秂侑毒 提交于 2021-02-11 08:17:25
问题 I am trying to change the timestamp from one format to another. I tried some approaches but i am not able to succeed. This is my timestamp 151005-12:07:34.917928 I would like to change it to a format like this 2015-10-05 12:07:34:917928 Thanks in Advance 回答1: Here's one way using regular expressions: import re e = '(\d{2})(\d{2})(\d{2})-(\d{2}:\d{2}:\d{2})\.(\d+)' s = '151005-12:07:34.917928' print('20{}-{}-{} {}:{}'.format(*re.search(e, s).groups())) 2015-10-05 12:07:34:917928 Here's another

python receiving image from socket stream

主宰稳场 提交于 2021-02-11 08:04:02
问题 I'm trying to send a frame and throw socket by python, using opencv . The image is sent as string stream but when i remake the image on the server,the bytes are not in the right order. Client code : import socket import numpy as np import cv2 UDP_IP = "127.0.0.1" UDP_PORT = 5005 cap = cv2.VideoCapture(1) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) while 1: ret, frame = cap.read() cv2.imshow('client', frame) d = frame.flatten() s = d.tostring() #sock.sendall(s) #print len(s) for i

OpenCV 2.4 estimateAffine3D in Python

↘锁芯ラ 提交于 2021-02-11 07:40:04
问题 I'm trying to use the method cv2.estimateAffine3D but without success. Here is my code sample : import numpy as np import cv2 shape = (1, 4, 3) source = np.zeros(shape, np.float32) # [x, y, z] source[0][0] = [857, 120, 854] source[0][1] = [254, 120, 855] source[0][2] = [256, 120, 255] source[0][3] = [858, 120, 255] target = source * 10 retval, M, inliers = cv2.estimateAffine3D(source, target) When I try to run this sample, I obtain the same error as this other post here. I'm using OpenCV 2.4

OpenCV 2.4 estimateAffine3D in Python

自作多情 提交于 2021-02-11 07:39:40
问题 I'm trying to use the method cv2.estimateAffine3D but without success. Here is my code sample : import numpy as np import cv2 shape = (1, 4, 3) source = np.zeros(shape, np.float32) # [x, y, z] source[0][0] = [857, 120, 854] source[0][1] = [254, 120, 855] source[0][2] = [256, 120, 255] source[0][3] = [858, 120, 255] target = source * 10 retval, M, inliers = cv2.estimateAffine3D(source, target) When I try to run this sample, I obtain the same error as this other post here. I'm using OpenCV 2.4

Difference between two dates in Pandas DataFrame

℡╲_俬逩灬. 提交于 2021-02-11 07:10:57
问题 I have many columns in a data frame and I have to find the difference of time in two column named as in_time and out_time and put it in the new column in the same data frame. The format of time is like this 2015-09-25T01:45:34.372Z . I am using Pandas DataFrame. I want to do like this: df.days = df.out_time - df.in_time I have many columns and I have to increase 1 more column in it named days and put the differences there. 回答1: You need to convert the strings to datetime dtype, you can then

Difference between two dates in Pandas DataFrame

空扰寡人 提交于 2021-02-11 07:09:59
问题 I have many columns in a data frame and I have to find the difference of time in two column named as in_time and out_time and put it in the new column in the same data frame. The format of time is like this 2015-09-25T01:45:34.372Z . I am using Pandas DataFrame. I want to do like this: df.days = df.out_time - df.in_time I have many columns and I have to increase 1 more column in it named days and put the differences there. 回答1: You need to convert the strings to datetime dtype, you can then

Difference between two dates in Pandas DataFrame

情到浓时终转凉″ 提交于 2021-02-11 07:09:18
问题 I have many columns in a data frame and I have to find the difference of time in two column named as in_time and out_time and put it in the new column in the same data frame. The format of time is like this 2015-09-25T01:45:34.372Z . I am using Pandas DataFrame. I want to do like this: df.days = df.out_time - df.in_time I have many columns and I have to increase 1 more column in it named days and put the differences there. 回答1: You need to convert the strings to datetime dtype, you can then