textwrap মডিউল TextWrapper ক্লাস প্রদান করে যা র্যাপিং বা ফিলিং করে। একই উদ্দেশ্যে এটি কনভেনিয়েন্স ফাংশনও প্রদান করে।
wrap(text)
text (একটি স্ট্রিং) এ একক প্যারাগ্রাফকে র্যাপ করে যাতে প্রতিটি লাইন সর্বোচ্চ width ক্যারেক্টার লং হয়। ফাইনাল নিউলাইন ছাড়া আউটপুট লাইনগুলো ধারণকারী একটি লিস্ট রিটার্ন করে।
fill(text)
text-এ একক প্যারাগ্রাফকে র্যাপ করে, এবং র্যাপ করা প্যারাগ্রাফ ধারণকারী একটি সিঙ্গেল স্ট্রিং রিটার্ন করে।
>>> sample_text = ''' The textwrap module provides some convenience functions, as well as TextWrapper class that does all the work. If you're just wrapping or filling one or two text strings, the convenience functions should be good enough; otherwise, you should use an instance of TextWrapper for efficiency. '''
>>> import textwrap
>>> for line in (textwrap.wrap(sample_text, width=50)):
print(line)
The textwrap module provides some convenience functions, as well as TextWrapper class that does all the work. If you're just wrapping or filling one or two text strings, the convenience functions should be good enough; otherwise, you should use an instance of TextWrapper for efficiency.
Fill উদাহরণ
>>> textwrap.fill(sample_text, width=50) ' The textwrap module provides some convenience\nfunctions, as well as TextWrapper class that\ndoes all the work. If you're just wrapping or\nfilling one or two text strings, the\nconvenience functions should be good enough;\notherwise, you should use an instance of\nTextWrapper for efficiency.'