Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74343 > unrolled thread
| Started by | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| First post | 2014-07-11 00:06 -0700 |
| Last post | 2014-07-11 05:26 -0400 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
base64 convert to binary by binascii is that right? Frank Liou <fk26541598fk@gmail.com> - 2014-07-11 00:06 -0700
Re:base64 convert to binary by binascii is that right? Dave Angel <davea@davea.name> - 2014-07-11 05:26 -0400
| From | Frank Liou <fk26541598fk@gmail.com> |
|---|---|
| Date | 2014-07-11 00:06 -0700 |
| Subject | base64 convert to binary by binascii is that right? |
| Message-ID | <6990c637-0d84-4ce4-b6ef-892290e56c74@googlegroups.com> |
conn = engine.connect()
encoded = base64.b64encode(getbody)
binary_string = binascii.a2b_base64(encoded)
puresql = sqla.text("INSERT INTO friends(name) VALUES(:binary_string)")
conn.execute(puresql,binary_string = binary_string)
first
getbody trans to base64
then i convert to binary
is that right?
getbody is '123AAA!!中文'
this is my result 123AAA\357\274\201\357\274\201\344\270\255\346\226\207
[toc] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-07-11 05:26 -0400 |
| Message-ID | <mailman.11757.1405070670.18130.python-list@python.org> |
| In reply to | #74343 |
Frank Liou <fk26541598fk@gmail.com> Wrote in message:
> conn = engine.connect()
> encoded = base64.b64encode(getbody)
> binary_string = binascii.a2b_base64(encoded)
> puresql = sqla.text("INSERT INTO friends(name) VALUES(:binary_string)")
> conn.execute(puresql,binary_string = binary_string)
>
>
Start by specifying Python version.
Since you're only asking about two lines, replace the rest with
something that people can actually run. And instead of just
printing binary_string, show its type as well.
--
DaveA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web