python-3.5

xlwings with python 3.5 on Windows

一曲冷凌霜 提交于 2019-12-02 13:11:46
问题 I have been stuck for some time. My configuration is: python 3.5 , xlwings 0.5.0 and Windows 7 . I get the following traceback while trying to import xlwings : Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Program Files\Python 3.5\lib\site-packages\xlwings\__init__.py", line 20, in <module> from . import _xlwindows as xlplatform File "C:\Program Files\Python 3.5\lib\site-packages\xlwings\_xlwindows.py", line 15, in <module> import pywintypes File "C:\Program

python selenium - webdriver wait until css_Selector visible

坚强是说给别人听的谎言 提交于 2019-12-02 12:27:13
text = browser.find_element_by_css_selector('.dbaListing.listing.lastListing > td:nth-child(4) > span').text This is what I want my webdriver to wait for to be located/visible. How do I do that? Use WebDriverWait with the visibility_of_element_located Expected Condition : from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC wait = WebDriverWait(browser, 10) element = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".dbaListing.listing.lastListing > td:nth-child(4) >

Python 3.5, ldap3 and modify_password()

回眸只為那壹抹淺笑 提交于 2019-12-02 11:32:39
问题 I've been pulling my hair out trying to send a request to update my own password via a script. here is the code: #!/usr/bin/python3.5 from ldap3 import Server, Connection, NTLM, ALL server = Server('ldap://192.168.0.80', use_ssl=True) conn = Connection(server, user="local\\dctest", password="Pa55word1", authentication=NTLM, auto_bind=True) dn = "CN=dctest,CN=Users,DC=home,DC=local" conn.extend.microsoft.modify_password(dn, new_password="Pa55word2", old_password="Pa55word1") The error that i

Python code, not able to write into xls

a 夏天 提交于 2019-12-02 10:49:31
When the below code is executed in Python 3.5 and xlwt 1.2.0, following error is generated: "Cannot convert byte objects to str implicitly" The code works fine for python 2.7. Anyone please let me know what could be the problem. Thanks in Advance!! import xlwt import re import os wb = xlwt.Workbook() ws = wb.add_sheet('A Test Sheet') ws_1 = wb.add_sheet('A Test Sheet_B') cnt_row = 0 cnt_col_1 = 0 cnt_col_2 = 0 path = "E:\Python_Scripts" files = os.listdir("E:\Python_Scripts") for filename in files: if filename.endswith(".ptu"): fo = open(os.path.join(path, filename), 'r') while(1): str = fo

PermissionError: pip upgrade from 8.1.1 to 8.1.2

余生颓废 提交于 2019-12-02 09:55:38
I am trying to upgrading pip from 8.1.1 to 8.1.2 . But it showing following 'PermissionError: [WinError 5] Access is denied : How to upgrade pip? C:\>python -m pip install --upgrade pip Collecting pip Using cached pip-8.1.2-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 8.1.1 Uninstalling pip-8.1.1: Exception: Traceback (most recent call last): File "C:\Program Files\Python35\lib\shutil.py", line 538, in move os.rename(src, real_dst) PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python35\\lib\\site-packages\\pip-8.1.1.dist-info\

Deleting File Lines in Python

安稳与你 提交于 2019-12-02 09:51:12
I am trying to create a program that takes in a username and high score, if they are already a user they update to their new high score or just adds the high score if not. My code is: try: a = open("data", "r+") except FileNotFoundError: a = open("data", "w") a = open("data", "r+") b = a.read() user = input("Username: ") user2 = list(user) if user in b: old = input("What is your old highscore? ") new = input("What is your new highscore? ") b2 = b.split() for line in b2: #Where I want to edit. line=line.replace(old, new) print(line) else: new = input("What is your highscore? ") a.write(user + "

Python 3 TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

回眸只為那壹抹淺笑 提交于 2019-12-02 08:46:26
#Import the module from math import sqrt #Using while loop statement to make the program not finish before the user close the program. while True: #Print out the introduction message, and get the input value to solve the quadratic equation. print("ax^2+bx+c=0의 꼴로 된 방정식을 풀 수 있습니다. a, b, c의 값을 차례대로 입력하세요.") a = input("a를 입력하세요 : ") b = input("b를 입력하세요 : ") c = input("c를 입력하세요 : ") #Define function that checks whether the input values are natural number or negative number def func_num(n): if n[0] == '-': n = -int(n[1:]) else: n = int(n) #Execute the function for the input value a, b, c func_num(a

Erratic encoding of byte to string on Python 3 on Ubuntu

丶灬走出姿态 提交于 2019-12-02 08:17:23
I'm new to Python and am working on a sensor. I'm building my code line by line and I have trouble with the encoding/decoding part for bytes to string. Same code, sometime it works, sometime it dosen't. Here is the code: import serial import time import os port = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=1, bytesize=8) f_w = open('/home/myname/python_serial_output.txt','r+') port.send_break() while True: op = port.read(2) op_str = op.decode('utf-8') f_w.write(op_str) print(op_str) It didn't work the first time round, but worked on the second time. Why? Here is the error I get:

Remove $ from a column of salaries python 3

淺唱寂寞╮ 提交于 2019-12-02 07:14:35
问题 I am trying to print the min and max from a list of salaries that I am reading from a csv file, but first I must remove the $ from the value and don't know how. I tried iterating through the list and using del[0] and got: SyntaxError: can't delete literal. I tried salary.replace("$", " ") and got: AttributeError: 'list' object has no attribute 'replace' I appended the salaries column to a list which is an immutable string. How would I remove the $ from a salary list that looks like [$98,500

Remove $ from a column of salaries python 3

大城市里の小女人 提交于 2019-12-02 05:34:10
I am trying to print the min and max from a list of salaries that I am reading from a csv file, but first I must remove the $ from the value and don't know how. I tried iterating through the list and using del[0] and got: SyntaxError: can't delete literal. I tried salary.replace("$", " ") and got: AttributeError: 'list' object has no attribute 'replace' I appended the salaries column to a list which is an immutable string. How would I remove the $ from a salary list that looks like [$98,500.85]? Thanks in advance. Hard to know the exact problem without the code, but you could try one of these: