import hashlib
infile = open("P:\\r.mp3", 'r+b')
data = infile.readline()
hash = hashlib.md5()
hash.update(data)
hash_digest = hash.hexdigest()
print(hash_digest)
#hash_digest = hash_digest.encode('utf-8')
print(hash_digest)
with open("lt.txt", 'ab') as outfile:
outfile.write(hash_digest + '\n') #error here
with open("syncDB.txt", 'rb') as fg:
for data in fg:
print(data)
outfile.write(hash_digest + '\n')
TypeError: 'str' does not support the buffer interface
मैं ऐसा कैसे को सही है और क्या मैं इन परिस्थितियों के माध्यम से मुझे देखने के लिए सीखने की जरूरत है ऐसा करने का समर्थन नहीं करता?लेखन त्रुटि: 'str' बफर इंटरफ़ेस
इसके अलावा, अगर मैं इस सांकेतिक शब्दों में बदलना utf-8 (टिप्पणी हटाएं) यह निम्न त्रुटि बाहर देता है:
TypeError: can't concat bytes to str
यदि आप खुले-साथ-साथ उपयोग कर रहे हैं तो आपको f.close() को कॉल करने की आवश्यकता नहीं है। (बेशक मुझे एहसास है कि आप बस ओपी के कोड से मेल खाते थे।) – DSM
धन्यवाद! मुझे 'csv.writer',' writer.writerow' के साथ एक ही त्रुटि के साथ समस्या थी। मुझे sys.stdout से 'open()' फ़ाइल में एडटर स्विचिंग में समस्याएं आ रही हैं। आपके समाधान ने मेरी समस्याओं का समाधान किया :)। –