Форум сайта python.su
import pyodbcНа выходи получаю разницу табл.1 и табл.2
connection = pyodbc.connect(
'DRIVER={SQL Server};'
'SERVER=TRASSIR-OFFICE\SQLEXPRESS;'
'DATABASE=master;'
'UID=sa;'
'PWD=12345'
)
if connection:
print (“Yes!\n”)
cursor = connection.cursor()
cursor.execute("SELECT distinct plate FROM master.dbo.testdax WHERE 1=1 AND plate NOT IN (SELECT FROM ..)")
results = cursor.fetchall ()
print (results)
cursor.close()
connection.close()
if results != 0 :
sql = (“INSERT INTO control(plate) VALUES (%results)” %results)
print (results)
else:
print (“test”)
import numpy as np import xlwt import sys from matplotlib import pylab as plt from PyQt5.QtWidgets import QApplication, QPushButton,QTableWidget, QSpinBox,QMessageBox from PyQt5.QtCore import Qt from PyQt5 import QtWidgets from PyQt5.QtWidgets import QWidget, QComboBox class mw(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.spin = QSpinBox(self) self.spin.move(10, 10) self.spin.setMaximum(100) self.spin.setMinimum(1) self.spin.valueChanged.connect(self.change) self.table = QTableWidget(self) self.table.resizeColumnsToContents() self.table.setColumnCount(6) self.table.setRowCount(int(self.spin.text())) self.table.setHorizontalHeaderLabels(["Диаметр л, мм","Диаметр о, мм","Разрушающая нагрузка, КН", "Высота, мм", "Ширина , мм","Форма "]) self.table.move(10, 50) self.table.horizontalHeaderItem(0).setTextAlignment(Qt.AlignHCenter) self.table.horizontalHeaderItem(1).setTextAlignment(Qt.AlignHCenter) self.table.horizontalHeaderItem(2).setTextAlignment(Qt.AlignHCenter) self.table.horizontalHeaderItem(4).setTextAlignment(Qt.AlignHCenter) self.table.horizontalHeaderItem(5).setTextAlignment(Qt.AlignHCenter) self.table.resize(1039, 100) self.table.resizeColumnsToContents() u= int(self.spin.text()) m =1 while m <= u: self.table.setItem(m, 5, QtWidgets.QTableWidgetItem(m)) self.combo = QComboBox(self.table) self.comboBox = QtWidgets.QComboBox() self.table.setCellWidget(m,5, self.combo) self.combo.addItem(str(1)) self.combo.addItem(str(np.pi / 4)) m = m + 1 # Делаем кнопку, по нажатию которой мы должны передаём данные дальше в обработку self.btn = QPushButton("OK", self) self.btn.move(80, 10) self.btn.resize(30, 30) self.btn.clicked.connect(self.get_data) self.setGeometry(0, 0, 1360, 1080) self.setWindowTitle("Application") self.show() def change(self): self.table.setRowCount(int(self.spin.text())) u = int(self.spin.text()) def get_data(self): Sit = 0 Pv = 0 Si3s=0 Ki = 0 TanFi0 = 0 Fi0 =0 C0i = 0 TanFi =0 Fi = 0 Ci = 0 Sis = 0 Sivs =0 Khr = 0 for i in range(self.table.rowCount()): dlunk=float(self.table.item(i, 0).text()) dot=float(self.table.item(i, 1).text()) Pkgs=float(self.table.item(i, 2).text()) a=float(self.table.item(i, 3).text()) b=float(self.table.item(i, 4).text()) N=float(self.table.item(i, 5).text()) if a <= 0 or b <= 0 or dot <= 0 or dlunk <= 0 or Pkgs <= 0: QMessageBox.about(ex, "Ошибка", "Вводимые данные должны быть больше нуля") else: S = a * b * N / 100 F = np.pi * dlunk * dot / 100 Sit = float(Pkgs / (10 * S)) Pv = Pkgs / (10 * F) TanFi0 = 0.5 * (Pv - Sit) / np.sqrt(Sit * Pv) Fi0 = np.arctan(TanFi0) * 180 / np.pi C0i = np.sqrt(Sit * Pv) TanFi = (np.sqrt(Pv) - np.sqrt(Sit)) * 0.5 / (np.sqrt(np.sqrt(Pv * Sit))) Fi = np.arctan(TanFi) * 180 / np.pi Ci = np.sqrt(np.sqrt(Pv * Sit)) * (np.sqrt(Pv) + np.sqrt(Sit)) * 0.5 Sis = Pv + np.sqrt(Sit * Pv) Sivs = 2 * Pkgs / (10 * (S + F)) Khr = Sis / Sivs Si3s = 2 * Pkgs if Khr < 5: sheet1.write(i, 17, "Значение не определить, т.к показатель меньше 5") if Khr > 5: KPuass = 1.4 / (Khr - 2.05) sheet1.write(i, 17, KPuass) Ki = Pv / Sit Sit = Sit + Sit Pv = Pv + Pv Si3s = Si3s+Si3s Ki = Ki + Ki TanFi0 = TanFi0 + TanFi0 Fi0 = Fi0 + Fi0 C0i = C0i + C0i TanFi = TanFi + TanFi Fi = Fi + Fi Ci = Ci + Ci Sis = Sis + Sis Sivs = Sivs + Sivs Khr = Khr + Khr Sit = Sit/i Pv = Pv/i Si3s=Si3s/i Ki = Ki / i TanFi0 = TanFi0 / i Fi0 = Fi0 / i C0i = C0i / i TanFi = TanFi / i Fi = Fi / i Ci = Ci / i Sis = Sis / i Sivs = Sivs / i Khr = Khr / i Xc1 = (-1) * Sit R1 = Sit Xc2 = 0 R2 = Sit * Pv * 2 / (Sit + Pv) Xc3 = (Pv - Sit) / 2 R3 = (Pv - Sit) / 2 Xc4 = (Pv + C0i) / 2 R4 = (Pv + C0i) / 2 Xc5 = (Pv + 2 * C0i + Sit) / 2 R5 = (Pv + 2 * C0i - Sit) / 2 Xc6 = Pv + C0i R6 = Pv Xc7 = (Pv + C0i) * (2 + np.sqrt(Pv / Sit)) / 2 R7 = (Pv + C0i) * np.sqrt(Pv / Sit) / 2 Xc8 = (Pv + C0i) * (Pv / Sit + np.sqrt(Pv / Sit) - 2) / 4 R8 = 3 * C0i / 2 + ((Pv - 3 * Sit) * Pv / Sit) / 4 Xc9 = (Pv + Sit) / 2 R9 = Sit + Pv / 2 def Mrc(x, r, x0): g = r * r - (x - x0) * (x - x0) y = np.sqrt(g) return y def Linep(g, g1, g2, v1, v2): v = g * (v2 - v1) / (g2 - g1) - g1 * (v2 - v1) / (g2 - g1) + v1 return v X_l1 = np.linspace(Xc1 - R1, Xc1 + R1, 1000) # графика кругов 1-8 Y1 = Mrc(X_l1, R1, Xc1) X_l2 = np.linspace(Xc2 - R2, Xc2 + R2, 100000) Y2 = Mrc(X_l2, R2, Xc2) X_l3 = np.linspace(Xc3 - R3, Xc3 + R3, 100000) Y3 = Mrc(X_l3, R3, Xc3) X_l4 = np.linspace(Xc4 - R4, Xc4 + R4, 100000) Y4 = Mrc(X_l4, R4, Xc4) X_l5 = np.linspace(Xc5 - R5, Xc5 + R5, 100000) Y5 = Mrc(X_l5, R5, Xc5) X_l8 = np.linspace(Xc8 - R8, Xc8 + R8, 100000) Y8 = Mrc(X_l8, R8, Xc8) X_l6 = np.linspace(Xc6 - R6, Xc6 + R6, 100000) Y6 = Mrc(X_l6, R6, Xc6) X_l9 = np.linspace(Xc9 - R9, Xc9 + R9, 100000) Y9 = Mrc(X_l9, R9, Xc9) X_l7 = np.linspace(Xc7 - R7, Xc7 + R7, 100000) Y7 = Mrc(X_l7, R7, Xc7) # конец кругов X_l9 = np.linspace(Xc9 - R9, Xc9 + R9, 100000) Y9 = Mrc(X_l9, R9, Xc9) if R6 > R8: Rmaxi = R6 Xmaxi = Xc6 else: Rmaxi = R8 Xmaxi = Xc8 YTau077 = 0.73 * Rmaxi XTau077 = Xmaxi - np.sqrt(Rmaxi * Rmaxi - YTau077 * YTau077) Lx1 = np.linspace((-2) * Sit, 0, 1000) # TAU1 = Linep(Lx1, 0, (-2) * Sit, Ci, 0) XLd = np.linspace(XTau077, Xmaxi, 1000) YLd = Mrc(XLd, Rmaxi, Xmaxi) Lx2 = np.linspace(0, XTau077, 1000) # TAU2 = Linep(Lx2, XTau077, 0, YTau077, Ci) Lmax = np.linspace(Xmaxi, 1.12 * Rmaxi + Xmaxi, 1000) TAUmax = Rmaxi + Lmax * 0 plt.plot(X_l1, Y1, 'blue', X_l2, Y2, 'blue', X_l3, Y3, 'blue', X_l4, Y4, 'blue', X_l5, Y5, 'blue', X_l6, Y6, 'blue', X_l7, Y7, 'blue', X_l8, Y8, 'blue') plt.plot(X_l9, Y9, 'blue', label='Круги Мора') plt.plot(Lx1, TAU1, 'red', Lx2, TAU2, 'red', XLd, YLd, 'r') plt.plot(Lmax, TAUmax, 'r', label='Огибающая') plt.legend() plt.xlabel(chr(963) + ", МПа") plt.ylabel(chr(964) + ", МПа") plt.axis('scaled') plt.ylim(0, ) plt.title("Паспорт прочности образца горной породы ") plt.grid() plt.show() Sic = Pv + C0i SiT = 2 * Sit * Pv / (Sit + Pv) Si3 = np.sqrt(Ki) * (Sic / 2 - 2 * Sit) Si1 = Sic + Ki * (Sic / 2 - 2 * Sit) Sib3 = Sit * (Si1 - Sit) / (Ki * (Si3 + Sit) - (Si1 - Sit)) Sib1 = ((Si1 - Sit) * Sib3 + Sit * (Si1 + Si3)) / (Si3 + Sit) FDx1 = np.linspace(-1 * SiT, (-1) * Sit, 1000) # графика кривой FD = Linep(FDx1, -1 * SiT, (-1) * Sit, Sit, Pv) DEx = np.linspace((-1) * Sit, Si3, 1000) # графика кривой DE = Linep(DEx, (-1) * Sit, Si3, Pv, Si1) ABx1 = np.linspace(0, Sib3, 1000) # графика кривой AB = Linep(ABx1, 0, Sib3, Sit, Sib1) BEx = np.linspace(Sib3, Si3, 1000) # графика кривой BE = Linep(BEx, Sib3, Si3, Sib1, Si1) Ch = np.linspace(-1 * Sit, Sib3) Cy = Linep(Ch, -1 * Sit, Sib3, Sit, Sib1) plt.plot(FDx1, FD, 'r') plt.plot(DEx, DE, 'r', label='') plt.plot(ABx1, AB, 'k', ) plt.plot(BEx, BE, 'k', label='') plt.plot(Ch, Cy, 'blue', label='') plt.legend() plt.xlabel(chr(963) + "3") plt.ylabel(chr(963) + "3") plt.ylim(0, ) plt.ylim(0, ) plt.grid() plt.show() if __name__ == '__main__': app = QApplication(sys.argv) ex = mw() sys.exit(app.exec_())
@app.route('/', methods=['POST']) @app.route('/index', methods=['POST']) def wifi_form(): wifi_ssid=request.form['ssid'] wifi_pass=request.form['password'] wifi_pare=(wifi_ssid, wifi_pass) result='success' cursor.execute("INSERT INTO wifi (ssid, password) VALUES (?, ?)", wifi_pare) conn.commit() return result
def del_form(): index=request.form['index'] result='disconnect' return result
<form action="" method="post" > <input id="ssid" type="text" name="ssid" style="display: none"> <select onChange="jQuery('#ssid').val(this.value);"> {% for wifi in wifi_list %} <option>{{ wifi }}</option> {% endfor %} </select> <input type="password" name="password"> <input type="submit" value="Connect"> </form> <form action="" method="post" > <input type="hidden" name="index" value="1"> <input type="submit" value="Disconnect"> </form>
self.m_textCtrl_text = rt.RichTextCtrl(self.panel, -1, self.text, wx.DefaultPosition, (500, 100))
urlStyle = rt.RichTextAttr() urlStyle.SetTextColour(wx.Colour(attrs['fill'])) urlStyle.SetFontUnderlined(strToBool(attrs['underline'])) self.m_textCtrl_text.BeginStyle(urlStyle) self.m_textCtrl_text.BeginURL(attrs['link']) self.m_textCtrl_text.WriteText(attrs['text']) self.m_textCtrl_text.EndURL() self.m_textCtrl_text.EndStyle()
import requests from bs4 import BeautifulSoup with requests.Session() as c: url = 'https://somesite.ru/login' LOGIN = '123' PASSWORD = 'qwerty' c.get(url) login_data = {'data[User][email]': LOGIN, 'data[User][password]': PASSWORD} r = c.post(url, data=login_data, timeout=None)
import requests requests.packages.urllib3.disable_warnings(InsecureRequestWarning) # Fill in your details here to be posted to the login form. payload = { 'loginFormUser_email': 'email', 'loginForm_password': 'password' } proxies = { 'http': 'http://user:passw@proxy:9090', 'https': 'http://user:passw@proxy:port' } headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'} # Use 'with' to ensure the session context is closed after use. with requests.Session() as s: r1 = s.get('https://ru.investing.com/', stream=True, verify=False, proxies=proxies, headers=headers) print(r1.status_code) --200 r2 = s.get('https://ru.investing.com/members-admin/auth/getSignInPopUp', stream=True, verify=False, proxies=proxies, headers=headers) print(r2.status_code) --200 # An authorised request. r3 = s.post('https://ru.investing.com/members-admin/auth/signInByEmail/', stream=True, verify=False, proxies=proxies, headers=headers, data=payload) print(r3.status_code) --200 r4 = s.get('https://ru.investing.com/commodities/gold-historical-data', stream=True, verify=False, proxies=proxies, headers=headers) print(r4.status_code) -200
import os, re, shutil, datetime pathNout = "C:\Comp nout" pathFlash = "E:\Comp in flash" pathflashBase = "E:\Comp in flash\Base flash" listDICOMfilesNout = os.listdir("C:\Comp nout") listDICOMfilesFlash = os.listdir("E:\Comp in flash") listDICOMfilesFlashBase = os.listdir("E:\Comp in flash\Base flash") firstfile = "" # 1. Опрееделние файла снимка на флешке с самым большим номером на флешке selection = re.compile(r"[а-яА-Яa-zA-Z0-9()_]*\.[DdCcMm]+") picsflash = selection.findall(str(listDICOMfilesFlash)) try: firstfile = max(picsflash) print("старший файл", firstfile) except: pass # удаление всех оставшихся файлов снимков на флешке кроме файла с послед номер try: picsflash.remove(firstfile) print(picsflash) forDeloldFile = [os.path.join(pathFlash, file) for file in picsflash] for file in forDeloldFile: os.unlink(file) except: pass # Поиск подходящих файлов снимков на ноуте selection = re.compile(r"[а-яА-Яa-zA-Z0-9()_]*\.[DdCcMm]+") pics = selection.findall(str(listDICOMfilesNout)) #Создание пути к каждому подходящему файлу снимка на ноуте suitablefiles = [os.path.join(pathNout, file) for file in pics] #2 Перенос файлов снимков с ноута на комп флешку, остановка на сопадающем файле try: for i in range(1,5000): shutil.copy(suitablefiles[-i], pathFlash) if pics[-i] == firstfile: break except: pass #3. Перенос файла базы на флешку selection = re.compile(r"[а-яА-Яa-zA-Z0-9()_]*\.[fdb]+") base = selection.findall(str(listDICOMfilesNout)) basePath = [os.path.join(pathNout, file) for file in base] for file in basePath: shutil.copy(file, pathflashBase) #4. Удаление последнего из файла предыдущей серии try: findelfile = os.path.join(pathFlash, firstfile) os.unlink(findelfile) except: pass
<div class="form-group"> <input type="hidden" name="parameters[179][0][text]"> <div class="col-lg-12"> <select class="form-control js-parameter-select" name="parameters[179][0][id]" data-placeholder="Состояние" style="display: none;"> <option value=""></option> <option value="1005">Бывшее в использовании</option> <option value="1004">Новое</option> </select> <div class="chosen-container chosen-container-single chosen-container-single-nosearch chosen-with-drop chosen-container-active" style="width: 100%;" title=""> <a class="chosen-single chosen-default"> <span>Состояние</span> <div><b></b></div></a> <div class="chosen-drop"> <div class="chosen-search"> <input type="text" autocomplete="off" readonly=""></div> <ul class="chosen-results"> <li class="active-result highlighted" data-option-array-index="1" style="">Бывшее в использовании</li> <li class="active-result" data-option-array-index="2" style="">Новое</li> </ul> </div></div></div></div>
<div class="form-group"><div class="col-lg-12"> <div class="chosen-container chosen-container-single chosen-container-single-nosearch chosen-with-drop chosen-container-active" style="width: 100%;" title=""> <div class="chosen-drop"> <div class="chosen-search">
import os import time import win32com.client dir_path = 'D:\\doc\\' wrd = win32com.client.Dispatch("Word.Application") wrd.visible = 0 for item in os.listdir(dir_path): if item.endswith(".doc"): print(item) file_name, file_exteniosn = os.path.splitext(item) file_path = os.path.join(dir_path, item) wb = wrd.Documents.Open(file_path) wb.Convert wb.SaveAs2(f'{file_path}x', FileFormat=16) wb.Close() wrd.Quit()
from docx import Document doc = Document(file_path) tb = doc.tables[0] fio_inn = tb.cell(3,3).tables[0].cell(0,0).text
function main(splash) assert(splash:go(splash.args.url)) splash:set_viewport_full() -- Wait split second to allow event to propagate. splash:wait(1) return { html = splash:html(), png = splash:png(), har = splash:har(), } end
def test(event): with open('C:\RetailBot\configs\proxy.json') as proxy_json: proxy = json.load(proxy_json) prox_driver = Proxy() prox_driver.proxy_type = ProxyType.MANUAL if proxy['get_type_proxy'] == 'HTTP': prox_driver.http_proxy = proxy['proxy'] if proxy['get_type_proxy'] == 'HTTPS': prox_driver.ssl_proxy = proxy['proxy'] if proxy['get_type_proxy'] == 'SOCKS 4/5': prox_driver.socks_proxy = proxy['proxy'] prox_driver.socks_username = proxy['get_login_proxy'] prox_driver.socks_password = proxy['get_password_proxy'] print(proxy) print(prox_driver) capabilities = webdriver.DesiredCapabilities.CHROME prox_driver.add_to_capabilities(capabilities) driver = webdriver.Chrome('C:\RetailBot\driver\chromedriver.exe', desired_capabilities=capabilities) driver.get("http://ipadresimnedir.com")
@bot.message_handler(content_types=['photo']) def handle_docs_photo(message): try: chat_id = message.chat.id text = message.text vid_id = message.chat.first_name file_info = bot.get_file(message.photo[len(message.photo)-1].file_id) downloaded_file = bot.download_file(file_info.file_path) src='/home/pi/test/'+file_info.file_path; with open(src, 'wb') as new_file: new_file.write(downloaded_file) bot.reply_to(message,"Foto add") img = open(src, 'rb') bot.send_photo(adminid, img) keyboard = types.InlineKeyboardMarkup(row_width=1) callback_bad = types.InlineKeyboardButton(text="KILL", callback_data='story[!!!]'+str(file_info.file_path)) keyboard.add(callback_bad) bot.send_message(adminid,"Add: "+vid_id , reply_markup=keyboard) except Exception as e: bot.send_message(adminid, e)
GridLayout { id: gridLayout columns: 4 Label { } TextField { Layout.columnSpan: 3 } }