This used to work before but now it has started displaying this error
#bot.slash_command(name="ping", description="Shows the ping", guild_ids=[988865437272010762])
AttributeError: 'Bot' object has no attribute 'slash_command'
Just use these lines of code
tree = bot.tree
#tree.command(name="ping", description="Shows the ping", guild_ids=[988865437272010762])
Of course, no need to redefine tree for each command.
Related
I get the error message in the title when I start this script. How could I solve it? Python 3.7
I haven't updated any modules, it worked perfectly. Now, this error comes out.
AttributeError: 'CallbackContext' object has no attribute 'message'
Here is the code: pastebin
def post(bot, update):
print(url)
url = update.message.text.replace("/g ","")
print(url)
driver.get(url)
nameele = driver.find_element_by_xpath("//*[#class='sqdOP yWX7d _8A5w5 ZIAjV ']")
You're using depercated syntax for handler callbacks. Since v12.0, the signature of handler callbacks reads def callback(update: telegram.Update, context: telegram.ext.CallbackContext):. Please see the v12 transition guide for details.
Do you know repl.it?
I am coding python on this site.
And my goal is creating Web Scraper.
I think this code is clean.
But I'm getting an error:
AttributeError: 'function' object has no attribute 'text'
My code:
import requests
indeed_result = requests.get
("https://kr.indeed.com/jobs?q=python&l=%EC%9D%B8%EC%B2%9C")
print(indeed_result.text)
Surely, I have requests package installed.
Please give me some advice
You just need to remove the back to new line after get like this:
import requests
indeed_result = requests.get("https://kr.indeed.com/jobs?q=python&l=%EC%9D%B8%EC%B2%9C")
print(indeed_result.text)
if you want to continue typping in the next line just add a backslash \ as follows:
indeed_result = requests.get\
("https://kr.indeed.com/jobs?q=python&l=%EC%9D%B8%EC%B2%9C")
Removing back to new line after get
try this
import requests
res = requests.get("https://kr.indeed.com/jobs?q=python&l=%EC%9D%B8%EC%B2%9C")
print(res.text)
# result if success 200
I have module with name Ioanv1:
...
person1={"temp_lags": [-21.96,-21.82,-21.89,-21.99]}
...
def ....
Now I want to replace person1 with new data in another script:
import json
import Ioanv1
person1={"temp_lags": [-21,-21,-21,-21]}
jsonToPython = Ioanv1(person1)
print(jsonToPython)
I get TypeError: 'module' object is not callable
Could you please help me.
Error message is simple and clear.
Ioanv1 is module
You are using Ioanv1(person1) which you can not.
You probably want something like: Ioanv1.person1
When writing the following code, the console shows an error:
AttributeError: 'NoneType' object has no attribute 'group'
The code:
req = re.search("([0-9]+)([A-Za-z]+)", data).group(0)
But, when debugging I see that there is a group, and the code continues to run instead of collapsing. For example when data is "30DIR /Users/user1/Documents/", the console outpost an error while debugging shows there is a match: "30DIR".
req = re.search("([0-9]+)([A-Za-z]+)", data)
if req:
req = req.group(0)
I am using scrapy 1.4,the version of twisted is 17.5.0,python is 3.6.3.
html is like this:
<span class="number"> 20</span>
when I run the spider,there is an error:
item['number'] = response.xpath('//span[#class="number"]/text()').extract_first().strip()
AttributeError: 'NoneType' object has no attribute 'strip'
what should I do?
Seems like problem is in the xpath that you wrote or in the document itself. extract_first method returns None if no match found. I've checked your example in online xpath validators and seems like everything is fine