import enchant
import wx
from enchant.checker import SpellChecker
from enchant.checker.wxSpellCheckerDialog import wxSpellCheckerDialog
from enchant.checker.CmdLineChecker import CmdLineChecker
a = "Ceci est un text avec beuacuop d'ereurs et pas snychro"
chkr = enchant.checker.SpellChecker("fr_FR")
chkr.set_text(a)
cmdln = CmdLineChecker()
cmdln.set_checker(chkr)
b = cmdln.run()
c = chkr.get_text() # returns corrected text
print c
Run Code Online (Sandbox Code Playgroud)
如何在c
不使用0
手动的情况下返回更正的文本cmdlinechecker
?
程序应该运行包含未修正文本的字符串,更正它,并将其保存在变量中以导出到MySQL数据库中.
我正在尝试使用图像生成PDF.
im = ImageReader('00001.png')
c = canvas.Canvas('networkanalyze.pdf', pagesize=A4)
c.drawImage(im, 10, 10, mask='auto')
c.showPage()
c.save()
Run Code Online (Sandbox Code Playgroud)
追溯:
Traceback (most recent call last):
File "pdf.py", line 9, in <module>
c.drawImage(im, 10, 10, mask='auto')
File "/usr/lib/python2.6/site-packages/reportlab-2.7-py2.6-linux-x86_64.egg/reportlab/pdfgen/canvas.py", line 909, in drawImage
rawdata = image.getRGBData()
File "/usr/lib/python2.6/site-packages/reportlab-2.7-py2.6-linux-x86_64.egg/reportlab/lib/utils.py", line 656, in getRGBData
annotateException('\nidentity=%s'%self.identity())
File "/usr/lib/python2.6/site-packages/reportlab-2.7-py2.6-linux-x86_64.egg/reportlab/lib/utils.py", line 653, in getRGBData
self._data = im.tostring()
File "/usr/lib/python2.6/site-packages/Pillow-3.2.0-py2.6-linux-x86_64.egg/PIL/Image.py", line 699, in tostring
"Please call tobytes() instead.")
Exception: tostring() has been removed. Please call tobytes() instead.
Run Code Online (Sandbox Code Playgroud)
第二种方法:
def generate_pdf(c):
"""
letter :- …
Run Code Online (Sandbox Code Playgroud) 使用 python 浏览 XML 的最简单方法是什么?
<html>
<body>
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:body>
<getservicebyidresponse xmlns="http://www.something.com/soa/2.0/SRIManagement">
<code xmlns="">
0
</code>
<client xmlns="">
<action xsi:nil="true">
</action>
<actionmode xsi:nil="true">
</actionmode>
<clientid>
405965216
</clientid>
<firstname xsi:nil="true">
</firstname>
<id xsi:nil="true">
</id>
<lastname>
Last Name
</lastname>
<role xsi:nil="true">
</role>
<state xsi:nil="true">
</state>
</client>
</getservicebyidresponse>
</soapenv:body>
</soapenv:envelope>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我会使用正则表达式并尝试获取我需要的行的值,但是有没有 Pythonic 的方法?诸如此类的东西xml[0][1]
?
我有这个 cURL 命令来与我的 API 对话:
curl -i -H "Content-Type: application/json" -X POST -d '{"sid":"01234567","text":"TEST","tlf":"123456","ctc":"123456","opr":"XYZ","fbm":"email@email.com","flag":"XYZ","product":"XYZ"}' http://XXX.XXX.XXX.XXX:8080/todo/api/v1.0/tasks
Run Code Online (Sandbox Code Playgroud)
哪个工作得很好,这里是响应:
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 24
Server: Werkzeug/0.11.3 Python/2.6.6
Date: Wed, 07 Jun 2017 10:03:00 GMT
Run Code Online (Sandbox Code Playgroud)
现在我想在同一个命令中发送一个 pdf 文件。
我想我补充说:
"file":"/var/www/html/olotool/API/attachments/pdf-test.pdf"
Run Code Online (Sandbox Code Playgroud)
最后但它被保存为字符串而不是文档。
如何在一个命令中添加它?
更新:
"file":"$(base64 ~/attachments/pdf-test.pdf)"
Run Code Online (Sandbox Code Playgroud)
将结果更改为<type 'file'>
它仍然是一个字符串,但至少它的内容不是(base64 ~/attachments/pdf-test.pdf)
.
我试着去理解一些东西
x = 10
print x
Run Code Online (Sandbox Code Playgroud)
结果将是 10
x is 10
print x
Run Code Online (Sandbox Code Playgroud)
结果将是错误 X 未定义。
x = 10
y = 10
if x == y:
print True
if x is y:
print True
Run Code Online (Sandbox Code Playgroud)
结果是:
True
True
Run Code Online (Sandbox Code Playgroud)
是否有另一种不使用等号来定义变量的方法?