Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

encoding strings in python

I am trying to encode a piece of text that I am getting from an Excel document. It contains all sorts of weird characters like quotation mark, backslashes, parentheses etc. What is the proper way to convert it to Python compatible string so I can process it and write it to a variable?

ExampleText = "MINIMUM TRACK FASTENING SHALL BE 0.145" DIAMETER POWDER ACTUATED FASTENERS (P.A.F.S) SPACED ON 8" CENTERS FOR BEARING WALLS, AND AT 12" O.C. FOR NON-LOAD BEARING WALLS (U.N.O.), WITH 1 1/2" MINIMUM PENETRATION INTO CONCRETE. AT X-BRACED SHEAR WALLS, TRACK SHALL BE ATTACHED PER DETAILS. At Infinity Shear Panels (ISP’S) attach to slab w/ 0.145" x 1 1/2" powder actuated fasteners spaced on 4" centers (HILTI DS 37 P10 or equal) -OR- (6) 3/8" DIA. 2205 expansion anchors w/ 2 1/2" min. embedment - OR-Simpson "Titen" screws @ 6" o.c."

I tried: str(ExampleText) but it obviously fails.

Thank you for help!

ps. Here's the error that I get: UnicodeEncodeError: ('unknown', '\x00', 0, 1, '') ps2. I am on IronPython2.7 i know a bummer :-(

Answer*

Draft saved
Draft discarded
Cancel

lang-py

AltStyle によって変換されたページ (->オリジナル) /