TGViewer
پایتون | Data Science | Machine Learning پایتون | Data Science | Machine Learning @python4all_pro · 24.2K subscribers
Post #147 8.11K
مدیریت فایل پایتون:

بررسی حالتهای مختلف دسترسی به فایل موجود در پایتون

🔸r : It opens the file to read-only. The file pointer exists at the beginning.
🔸rb : It opens the file to read-only in the binary format.
🔸r+ : It opens the file to read and write both.
🔸rb+ : It opens the file to read and write both in the binary format.
🔸 w : It opens the file to write only. It overwrites the file if previously exists or creates a new one if no file exists with the same name.
🔸wb : It opens the file to write only in the binary format
🔸w+ : It opens the file to write and read both. It is different from r+ in the sense that it overwrites the previous file if one exists whereas r+ doesn’t overwrite the previously written file.
🔸wb+ : It opens the file to write and read both in the binary format
🔸a : It opens the file in the append mode.
🔸ab : It opens the file in the append mode in the binary format.
🔸a+ : It opens a file to append and read both.
🔸ab+ : It opens a file to append and read both in the binary format.

with open("hello.txt", "w+") as f:
f.write("Hello World")
f.seek(0)
print(f.read())



🆔 @Python4all_pro
  • 👍 5
  • ❤ 1
More from @python4all_pro
  1. Oct 6, 2026#ایونت_آنلاین مجازی‌سازی؛ قلب پنهان زیرساخت👀 اگه به شبکه، سرور و زیرساخت علاقه داری، احتم…
  2. Oct 6, 2026🔴🔴ماهی 3 پروژه 20 میلیونی این شغل 60 میلیون بهت درآمد میده ۳۰ نفری که در تیم ما استخدام…
  3. Oct 4, 2026‌🔴 خبر فوری — انتخاب رشته هوشمند و رایگان با «مسیر» 🔥 «مسیر» نرم‌افزار هوشمند و کاملاً ر…
  4. Sep 29, 2026What better way to understand a powerful tool like Claude Code than to build your own vers…
  5. Sep 28, 202625 GitHub Repositories Every Python Developer Should Know! Want to improve your Python ski…
  6. Sep 27, 202640+ FREE Python Books from Amazon! Want to improve your Python skills without spending a f…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →