मैं स्टैक ओवरफ़्लो से प्रश्न पुनर्प्राप्त करने के लिए प्रोग्राम पर काम कर रहा हूं। कल तक कार्यक्रम ठीक काम कर रहा था, लेकिन आज के बाद से मैं त्रुटिUnicodeEncodeError: 'ascii' कोडेक स्थिति 34 में वर्ण n201c 'एन्कोड नहीं कर सकता है: क्रमशः श्रेणी में नहीं (128)
"Message File Name Line Position
Traceback
<module> C:\Users\DPT\Desktop\questions.py 13
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 34: ordinal not in range(128)"
वर्तमान में प्रश्न प्रदर्शित किए जाते हैं हो रही है लेकिन मैं एक नया पाठ फ़ाइल में उत्पादन की प्रतिलिपि नहीं बना होने लगते हैं।
import sys
sys.path.append('.')
import stackexchange
so = stackexchange.Site(stackexchange.StackOverflow)
term= raw_input("Enter the keyword for Stack Exchange")
print 'Searching for %s...' % term,
sys.stdout.flush()
qs = so.search(intitle=term)
print '\r--- questions with "%s" in title ---' % (term)
for q in qs:
print '%8d %s' % (q.id, q.title)
with open('E:\questi.txt', 'a+') as question:
question.write(q.title)
time.sleep(10)
with open('E:\questi.txt') as intxt:
data = intxt.read()
regular = re.findall('[aA-zZ]+', data)
print(regular)
tokens = set(regular)
with open('D:\Dictionary.txt', 'r') as keywords:
keyset = set(keywords.read().split())
with open('D:\Questionmatches.txt', 'w') as matches:
for word in keyset:
if word in tokens:
matches.write(word + '\n')
कौन सा लाइन इस त्रुटि उत्पन्न कर रहा है के साथ फिक्स्ड का उपयोग कर? इसके अलावा, रेगेक्स '[एए-जेडजेड] + 'ऐसा नहीं करेगा जो आपको लगता है कि यह करता है। आपको '[ए-ज़ा-जेड] +' या '(? I) [ए-जेड] +' की आवश्यकता है। –
question.write (q.title) त्रुटि उत्पन्न कर रहा है। –
मैं केवल शब्दों को निकालने और संख्याओं और विशेष वर्णों को अनदेखा करने के लिए ** [एए-जेडजेड] + ** का उपयोग कर रहा हूं। –