$ python
Python 3.10.2 (main, Mar 8 2022, 23:56:15) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from getmac import get_mac_address
>>> ip_mac = get_mac_address(ip="192.168.1.1")
$ python
Python 3.10.2 (main, Mar 8 2022, 23:56:15) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> df = pd.DataFrame([[1,2,3],[3,4,5]])
>>> df
0 1 2
0 1 2 3
1 3 4 5
>>> df.values.tolist()
[[1, 2, 3], [3, 4, 5]]
import ftplib
HOST = 'server'
USER = 'ftpuser'
PASSWD = 'ftppass'
FILE = 'file.ext'
FTP_DIR = 'dir'
with ftplib.FTP(HOST) as ftp:
try:
ftp.login(user=USER, passwd = PASSWD)
ftp.cwd(FTP_DIR)
with open(FILE, 'wb') as fp:
ftp.retrbinary('RETR ' + FILE, fp.write)
except ftplib.all_errors as err:
print('FTP error:', err)
from math import tan, log
x = float(input("Enter x: "))
K = 5.498
L = 0.995
M = 3.14
a = K - x / 12
b = L + tan(log(x)) + 2 * M
if a > b:
print("y =", log(a - b))
elif a < b:
print("y =", log(b - a))
else:
print("Логарифм не определён при нулевом значении аргумента")
fact = random.choice(html.find_all('h2', class_='entry-title'))
$ python3
Python 3.10.2 (main, Mar 8 2022, 23:56:15) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> '123'.isdigit()
True
>>> '123+'.isdigit()
False
>>> '123a'.isdigit()
False
Хочу по приколу сделать бота в телеграмме
Я в питоне очень плохо понимаю
title = post.find("a", class_="post__title_link").text.strip()
post__title_link
, то post.find("a", class_="post__title_link")
принимает значение None
. Отсюда ошибка AttributeError: 'NoneType' object has no attribute 'text'
. import numpy as np
import pandas as pd
df = pd.DataFrame([[np.nan, 'f+2', np.nan, '0'],
['3', '4', np.nan, 'y1,et'],
[np.nan, np.nan, np.nan, np.nan],
[np.nan, '3', np.nan, 'w$4q']],
columns=list("ABCD"))
print(df)
df.replace(to_replace=r'[a-zA-Z+$,]', value='', inplace=True, regex=True)
print(df)
df = df.fillna(0.0)
df = df.astype(float)
print(df)
A B C D
0 NaN f+2 NaN 0
1 3 4 NaN y1,et
2 NaN NaN NaN NaN
3 NaN 3 NaN w$4q
A B C D
0 NaN 2 NaN 0
1 3 4 NaN 1
2 NaN NaN NaN NaN
3 NaN 3 NaN 4
A B C D
0 0.0 2.0 0.0 0.0
1 3.0 4.0 0.0 1.0
2 0.0 0.0 0.0 0.0
3 0.0 3.0 0.0 4.0
Как запустить код на библиотеке selenium_stealth без монитора?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium_stealth import stealth
import time
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("--headless")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options)
stealth(driver,
languages=["en-US", "en"],
vendor="Google Inc.",
platform="Win32",
webgl_vendor="Intel Inc.",
renderer="Intel Iris OpenGL Engine",
fix_hairline=True,
)
url = "https://bot.sannysoft.com/"
driver.get(url)
time.sleep(5)
driver.quit()