2013-10-09 2 views
2

내가 데이터 'ascii'코덱은 319 위치의 바이트 0xef를 디코딩 할 수 없습니다. 서수는 범위 (128)에 있지 않습니까? 여기

post = """ 
='Brand New News Fr0m The Timber Industry!!'= 

========Latest Profile========== 
Energy & Asset Technology, Inc. (EGTY) 
Current Price $0.15 
================================ 

Recognize this undiscovered gem which is poised to jump!! 

Please read the following Announcement in its Entierty and 
Consider the Possibilities� 
Watch this One to Trad,e! 

Because, EGTY has secured the global rights to market 
genetically enhanced fast growing, hard-wood trees! 

EGTY trading volume is beginning to surge with landslide Announcement. 
The value of this Stoc,k appears poised for growth! This one will not 
remain on the ground floor for long. 

KEEP READING!!!!!!!!!!!!!!! 

=============== 
"BREAKING NEWS" 
=============== 

-Energy and Asset Technology, Inc. (EGTY) owns a global license to market 
the genetically enhanced Global Cedar growth trees, with plans to 
REVOLUTIONIZE the forest-timber industry. 

These newly enhanced Globa| Cedar trees require only 9-12 years of growth 
before they can be harvested for lumber, whereas worldwide growth time for 
lumber is 30-50 years. 

Other than growing at an astonishing rate, the Global Cedar has a number 
of other benefits. Its natural elements make it resistant to termites, and 
the lack of oils and sap found in the wood make it resistant to forest fire, 
ensuring higher returns on investments. 
T 
he wood is very lightweight and strong, lighter than Poplar and over twice 
as strong as Balsa, which makes it great for construction. It also has 
the unique ability to regrow itself from the stump, minimizing the land and 
time to replant and develop new root systems. 

Based on current resources and agreements, EGTY projects revenues of $140 
Million with an approximate profit margin of 40% for each 9-year cycle. With 
anticipated growth, EGTY is expected to challenge Deltic Timber Corp. during 
its initial 9-year cycle. 

Deltic Timber Corp. currently trades at over $38.00 a share with about $153 
Million in revenues. As the reputation and demand for the Global Cedar tree 
continues to grow around the world EGTY believes additional multi-million 
dollar agreements will be forthcoming. The Global Cedar nursery has produced 
about 100,000 infant plants and is developing a production growth target of 
250,000 infant plants per month. 

Energy and Asset Technology is currently in negotiations with land and business 
owners in New Zealand, Greece and Malaysia regarding the purchase of their popular 
and profitable fast growing infant tree plants. Inquiries from the governments of 
Brazil and Ecuador are also being evaluated. 

Conclusion: 

The examples above show the Awesome, Earning Potential of little 
known Companies That Explode onto Investor�s Radar Screens. 
This s-t0ck will not be a Secret for long. Then You May Feel the Desire to Act Right 
Now! And Please Watch This One Trade!! 


GO EGTY! 


All statements made are our express opinion only and should be treated as such. 
We may own, take position and sell any securities mentioned at any time. Any 
statements that express or involve discussions with respect to predictions, 
goals, expectations, beliefs, plans, projections, object'ives, assumptions or 
future events or perfo'rmance are not 
statements of historical fact and may be 
"forward,|ooking statements." forward,|ooking statements are based on expectations, 
estimates and projections at the time the statements are made that involve a number 
of risks and uncertainties which could cause actual results or events to differ 
materially from those presently anticipated. This newsletter was paid $3,000 from 
third party (IR Marketing). Forward,|ooking statements in this action may be identified 
through the use of words such as: "pr0jects", "f0resee", "expects". in compliance with 
Se'ction 17. {b), we disclose the holding of EGTY shares prior to the publication of 
this report. Be aware of an inherent conflict of interest resulting from such holdings 
due to our intent to profit from the liquidation of these shares. Shar,es may be sold 
at any time, even after positive statements have been made regarding the above company. 
Since we own shares, there is an inherent conflict of interest in our statements and 
opinions. Readers of this publication are cautioned not 
to place undue reliance on 
forward,|ooking statements, which are based on certain assumptions and expectations 
involving various risks and uncertainties that could cause results to differ materially 
from those set forth in the forward- looking statements. This is not solicitation to 
buy or sell st-0cks, this text is or informational purpose only and you should seek 
professional advice from registered financial advisor before you do anything related 
with buying or selling st0ck-s, penny st'0cks are very high risk and you can lose your 
entire inves,tment. 
""" 

In [147]: post.encode('utf-8') 

을 인코딩하고 있는데 출력

UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 319: ordinal not in range(128) 
+2

당신은 이미 바이트 문자열을 가지고, 다시 인코딩해야하는 이유는 무엇입니까? 이것을 인코딩하려고하면 먼저 유니 코드로 디코딩 *해야합니다. –

+0

답장을 보내 주셔서 감사합니다. 게시물 변수에 디코드를 사용하고 있습니다. 그런 다음 인코딩을 적용한 후. 그러나 그것은 같은 오류를 주었다. – dhana

+0

먼저 이것을 보시기 바랍니다 : [Pragmatic Unicode, 또는 어떻게 고통을 멈 춥니 까?] (http://www.youtube.com/watch?v=sgHbC6udIqc) –

답변

3

유니 코드를 얻고 것은 (모든) 알려진 문자, 문자 및 징후, 종종라는 상형 문자를 포함하려고 테이블입니다 . 그것은 110000 이상의 다소 징후를 지키는 의미입니다. 따라서 DECODED 상태는이 테이블의 (코드) 지점입니다. 그러나 바이트가 8 비트 = 256 상태 이상을 유지할 수 없기 때문에 유니 코드 표현을 바이트 스트림으로 인코딩해야합니다. 가장 많이 사용되는 인코딩 기법은 UTF-8 인코딩 (UTF-8 ENCODING)으로, 이전의 ASCII 인코딩에 이어 사용됩니다. UTF-8 인코딩은 1에서 4 바이트의 유니 코드 문자 모양을 인코딩 할 수 있습니다.

인코딩 또는 디코딩은 항상 유니 코드 또는 유니 코드를 향합니다. 당신이 한 인코딩에서 다른 변환 할 경우, 유니 코드를 통해 그것을 할 수 있습니다

[decode]  [encode] 
ASCII ---> UNICODE ---> UTF-8 
1 Glyph     1 Glyph 
    =  1 Glyph  = 
1 Byte     1-4 Bytes 

unicode_str = mystring.decode('ascii') 
    utf8_str = unicode_str.encode('utf-8') 

(안 최고의 예를 들어, ASCII는 항상 UTF-8에 맞는 때문에)

따라서 post 변수를 디코드하려면 참조 된 문자열이있는 인코딩을 알아야합니다. 파이썬 2.x에서는 일반적으로 ASCII로 인코딩됩니다. 파이썬 3.x에서는 UTF-8이어야합니다. 당신의 post - 변수가 외부 바이트 스트림에서 소스 코드에 정의되어 있지만, 읽을 수없는 경우

import sys 
print sys.getdefaultencoding() 

당신은 인코딩을 알고 있어야합니다 또는 당신이 운이 될 것입니다. 당신이 파일의 두 번째 라인을 만들어 사용중인 인코딩 (첫 번째 또는 당신이 오두막을 사용하지 않는 경우)

3

첫째, 파이썬 알려주기 :

# coding=utf-8 

( PEP 263 참조)

다음, 대신 바이트 문자열을 사용, 항상 텍스트 콘텐츠 유니 코드 리터럴을 사용

post = u""" 
='Brand New News Fr0m The Timber Industry!!'= 
etc. etc. etc.""" 
관련 문제