Форум сайта python.su
import sys import os, commands from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") # show excel xlApp.Visible=False # create an XLS file # load a pre-created excel sheet sheet_file_name = r"c:\1\22.xls" try: xlBook = xlApp.Workbooks.Open(sheet_file_name, 0, False, 2) except Exception as inst: print "Content-type: text/html\n\n"; print(sheet_file_name) print(inst) xlSheet = xlBook.Sheets(1) xlSheet.Name = "My Chart" xlSheet.Cells(1,1).Value="My Chart" xlSheet.Cells(2,1).Value="2" xlSheet.Cells(3,1).Value="8" xlSheet.Cells(4,1).Value="32" xlSheet.Cells(5,1).Value="50" xlSheet.Cells(5,2).Value="100" xlSheet.Cells(6,1).Value="25" xlSheet.Cells(6,2).Value="50" xlSheet.Cells(7,1).Value="25" xlSheet.Cells(7,2).Value="50" xlSheet.Cells(8,1).Value="25" xlSheet.Cells(8,2).Value="50" xlSheet.Cells(9,1).Value="25" xlSheet.Cells(9,2).Value="50" chart1=xlSheet.ChartObjects(1) chartObject = xlSheet.ChartObjects(1) chart1 = chartObject.chart chart1.SetSourceData(Source=xlSheet.Range("A1:B9")) chart1.HasTitle = True chart1.ChartTitle.Characters.Text ="title 11111" chart1.Type = -4102 chart1.Elevation = 15 chart1.ChartArea.Fill.ForeColor.SchemeColor = 49 chart1.ChartArea.Fill.BackColor.SchemeColor = 20 chart1.ChartTitle.Font.Size = 24 chart1.ChartTitle.Font.ColorIndex = 2 xlBook.Close(SaveChanges=1) xlApp.Quit() del xlApp
import urllib.request as ur from bs4 import BeautifulSoup req = ur.Request('http://rghost.ru/search?s=.jpg') data = ur.urlopen(req) html = data.read().decode('utf8', 'replace') soup = BeautifulSoup(html) print(soup.prettify())
Traceback (most recent call last): File "C:\Python32\MYPROJ\django\fotoagregate\testing.py", line 11, in <module> print(soup.prettify()) File "C:\Python32\lib\encodings\cp1251.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' in position 3043: character maps to <undefined> [Finished in 1.6s with exit code 1]
class file_dialog(): def __init__(self): self.file_dialog_ui = uic.loadUi("file_dialog.ui") self.file_dialog_ui.show()
import file_dialog as fd dir = fd.file_dialog()
cat /dev/ttyUSB0
import serial keyboard_port = '/dev/input/event0' ser = serial.Serial(port=keyboard_port) ser.write('Yes!') ser.close()
serial.serialutil.SerialException: Could not configure port: (22, 'Invalid argument')
$xmlFileName = dirname(__FILE__)."/books/1.fb2"; $xml = new DOMDocument(); $xml->load($xmlFileName); $xslFileName = dirname(__FILE__)."/xslts/1.xsl"; $xsl = new DOMDocument; $xsl->load($xslFileName); // Configure the transformer $proc = new XSLTProcessor(); $proc->importStyleSheet($xsl); // attach the xsl rules echo $proc->transformToXML($xml);