Форум сайта python.su
from pyvirtualdisplay import Display display = Display(visible=0, size=(800, 600)) display.start() #тело скрипта display.stop()
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32 >>> round(2.675, 2) 2.67 >>> round(2.685, 2) 2.69
Server version: 5.5.34 MySQL Community Server (GPL) mysql> select round(2.675, 2); +-----------------+ | round(2.675, 2) | +-----------------+ | 2.68 | +-----------------+ 1 row in set (0.00 sec) mysql> select round(2.685, 2); +-----------------+ | round(2.685, 2) | +-----------------+ | 2.69 | +-----------------+ 1 row in set (0.00 sec)
#!/usr/bin/env python # -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui import sys class MyWindow(QtGui.QMainWindow): def __init__(self, parent = None): QtGui.QMainWindow.__init__(self, parent) self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.WindowSystemMenuHint) # Menu configure self.menuFile = QtGui.QMenu("&File") self.actOpen = QtGui.QAction("Open", None) self.actOpen.setShortcut(QtGui.QKeySequence.Open) self.actOpen.triggered.connect(self.on_open) self.menuFile.addAction(self.actOpen) self.menuBar().addMenu(self.menuFile) def on_open(self): print("Выбран пункт меню Open") #Вызов диалога в котором надо управлять фокусом f = QtGui.QFileDialog.getOpenFileName(parent=self, caption="Open File") print "Selected file: ", f app = QtGui.QApplication(sys.argv) window = MyWindow() window.show() sys.exit(app.exec_())
from math import * import numpy as np import matplotlib.pyplot as plt def f(x,s,m): return (1./(sqrt(2.*pi)*s))*e**(-0.5*((x-m)/s)**2) def main(): m = 0 s = np.linspace(0.5,5,3) x = np.linspace(-10,10,20) for i in range(3): print('s = ', s[i]) for j in range(20): f(x[j],s[i],m) print('x = ',x[j],', y = ',f(x[j],s[i],m))
from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys import time profile = webdriver.FirefoxProfile() profile.set_preference('network.proxy.type', 1) profile.set_preference("network.proxy.socks","socks_ip") profile.set_preference("network.proxy.socks_port","socks_port") profile.update_preferences() browser = webdriver.Firefox(profile) # Get local session of firefox browser.get("http://www.domain.com") # Load page browser.close()
list_links = driver.find_element_by_xpath(u'//img/ancestor::a[not(re:match(@href, "(slovo1|slovo2)")) ]/@href', namespaces={"re": "http://exslt.org/regular-expressions"})
got an unexpected keyword argument 'namespace'
list_links = driver.find_element_by_xpath("//img/ancestor::a/@href")
invalidselectorerror
def move(n, start, finish): if start == 2 or finish == 2: if n > 0: temp = 6 - start - finish move(n - 1, start, temp) move(n - 1, temp, finish) print(n, start, finish) else: if n > 0: temp = 6 - start - finish move(n - 1, start, finish) move(n, start, temp) move(n - 1, finish, start) move(n, temp, finish) move(n - 1, start, finish) print(n, start, finish) n = int(input()) print(move(n,1,3))