import openpyxl as xl
wb=xl.load_workbook("C:\\praveen\\python\\Excel\\Book1.xlsx")
title_column_name="Name"
ws=wb.active
searchstring="joe"
for row in list(ws.rows)[1:]:
if row[1].value.find(searchstring)!= -1:
print("found a matching row!slno={0}, name={1}, subject={2}, marks={3}".format(row[0].value, row[1].value, row[2].value. row[3].value))
Error output:
AttributeError: 'str' object has no attribute 'row'
Related
import subprocess
def check_output(cmd):
""" https://docs.python.org/2/library/subprocess.html#subprocess.Popen
Implementation subprocess.check_output() for Python 2.6
"""
process_list = []
cmd_list = cmd.strip().split("|")
for i, sub_cmd in enumerate(cmd_list):
STDIN = None
if i > 0:
STDIN = process_list[i - 1].stdout
process_list.append(subprocess.check_output(sub_cmd, stdin=STDIN, stdout=subprocess.PIPE, shell=True))
if len(process_list) == 0:
return ''
output = process_list[i].communicate()[0]
return output
print(check_output('ls -la /var | grep log'))
I am facing issue of AttributeError: 'module' object has no attribute 'check_output' in Thonny python Every time run my program, I tried call() also but it is showing same error
After calling this method it shows me this error 'str' object has no attribute 'is_stale': response = client.get_products(37.77, -122.41)
this is source code:
import sys from uber_rides.session
import Session from uber_rides.client
import UberRidesClient
session = Session(oauth2credential='[redacted]')
client = UberRidesClient(session)
response = client.get_products(37.77, -122.41)
Traceback:
Traceback (most recent call last):
File "/Users/mhv/Projects/Other/Python/Uber/main.py", line 12, in <module>
response = client.get_products(37.77, -122.41)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uber_rides/client.py", line 128, in get_products
return self._api_call('GET', 'v1.2/products', args=args)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uber_rides/client.py", line 96, in _api_call
self.refresh_oauth_credential()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/uber_rides/client.py", line 720, in refresh_oauth_credential
if credential.is_stale():
AttributeError: 'str' object has no attribute 'is_stale'
Best regards
myRDD.collect()
gives below output:
[('best', {'times'}),
('age', {'foolishness', 'times', 'wisdom'}),
('wisdom', {'age'}),
('times', {'age', 'best', 'worst'}),
('worst', {'times'}),
('foolishness', {'age'})]
When I attempt to split contents here in spark using:
myRDD.map(lambda line: line.split(','))
I get an error: AttributeError: 'tuple' object has no attribute 'split'
My expected outcome is below:
[(‘times’, [(‘best’)]),
(‘times’, [(‘worst’)]),
(‘age’, [(‘foolishness’)]),
(‘foolishness’, [(‘age’)]),
(‘wisdom’, [(‘age’)]),
(‘times’, [(‘age’)]),
(‘age’, [(‘wisdom’)]),
(‘age’, [(‘times’)]),
(‘best’, [(‘times’)]),
(‘worst’, [(‘times’)])]
import tensorflow as tf
flags = tf.app.flags
AttributeError: module 'tensorflow' has no attribute 'app'
Try to use: import tensorflow.compat.v1 as tf
I am encountering this error always when getting a response from a websocket connection:
print type(json.dumps(data))
TypeError: 'unicode' object is not callable
also:
print type(data)
TypeError: 'unicode' object is not callable
and:
print type(str(data))
TypeError: 'unicode' object is not callable
Can anyone teach me how to encode the data string back to utf-8?
You (or a library you use, but more likely you) have overwritten the variable type in the global scope.
Here I'm breaking stuff in the same way:
>>> type(1)
<type 'int'>
>>> type(u'9')
<type 'unicode'>
>>> type('9')
<type 'str'>
>>> type = u'i'
>>> type(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'unicode' object is not callable
To encode Unicode string into UTF-8 bytestring, call .encode('UTF-8'):
>>> u'€'.encode('utf-8')
'\xe2\x82\xac'