Python ফাইল write() পদ্ধতি
উদাহরণ
"a"-তে ফাইল খোলা এবং ফাইলে কিছু টেক্সট যোগ করুন:
f = open("demofile2.txt", "a") f.write("See you soon!") f.close() #open and read the file after the appending: f = open("demofile2.txt", "r") print(f.read())
বিবরণ ও ব্যবহার
write() পদ্ধতি নির্দিষ্ট টেক্সটকে ফাইলে লিখে দেবে。
নির্দিষ্ট টেক্সটটি প্রবর্তন করার স্থান ফাইল মোড ও স্ট্রিম স্থানের উপর নির্ভর করে।
গ্রামাট
file.write(বাইট)
পারামিটার মান
পারামিটার | বর্ণনা |
---|---|
বাইট | প্রবর্তন করতে হবের টেক্সট বা বাইট অবজেক্ট |
আরও উদাহরণ
উদাহরণ
যেমন আগের উদাহরণ, কিন্তু সম্প্রসারিত টেক্সটের আগে একটি লাইন প্রবর্তন করা হয়েছে:
f = open("demofile2.txt", "a") f.write("\nSee you soon!") f.close() #open and read the file after the appending: f = open("demofile2.txt", "r") print(f.read())