قم بتنزيل VSCode من webpage وقم بتثبيته.
بالنسبة لدورة المبتدئين، يجب عليك تثبيت Python extension
لـ VSCode.
عند فتح VSCode، في الشريط الجانبي الأيسر، اختر Extensions
(Ctrl + Shift + X) مع رمز المكعبات الأربعة.
بعد ذلك، في شريط البحث العلوي لـ Extensions، ابحث عن "Python" وفي قائمة الإضافات التي تظهر، حدد وقم بتثبيت الحزمة الأولى المقترحة: Python
- من تأليف Microsoft. يمكنك تثبيت الحزمة بالنقر فوق الزر الصغير "Install" الموجود في أسفل العنصر في القائمة أو بعد النقر على العنصر في اللوحة المفتوحة حديثًا وفي أعلى الصفحة، يجب أن يكون هناك زر صغير "install".
تعمل التحكم بالمسافات التلقائية(indentation) وتلوين الكود المطلوب (لأغراضنا) فقط عندما يكون الملف يحتوي على امتداد .py
.
لذلك من الأفضل أن تحفظ الملف الذي تم إنشاؤه حديثًا بامتداد .py
في أقرب وقت ممكن.
من المهم في بايثون مقدار المسافات التي يتم فيها استطالة سطر ما. لذلك علينا أن نتعلم سريعا كيفية التحكم بالمسافات لقطعة من النص.
أولاً، انسخ النص التالي في المحرر (editor) الخاص بك.
OPHELIA:
Good my lord,
How does your honour for this many a day?
HAMLET:
I humbly thank you; well, well, well.
OPHELIA:
My lord, I have remembrances of yours,
That I have longed long to re-deliver;
I pray you, now receive them.
HAMLET:
No, not I;
I never gave you aught.
OPHELIA:
My honour'd lord, you know right well you did;
And, with them, words of so sweet breath composed
As made the things more rich: their perfume lost,
Take these again; for to the noble mind
Rich gifts wax poor when givers prove unkind.
There, my lord.
Hamlet, W. Shakespeare
هذا النص غير مرتب جيدًا، لذلك سنقوم ب ضبط فراغاته على النحو التالي:
OPHELIA:
Good my lord,
How does your honour for this many a day?
HAMLET:
I humbly thank you; well, well, well.
OPHELIA:
My lord, I have remembrances of yours,
That I have longed long to re-deliver;
I pray you, now receive them.
HAMLET:
No, not I;
I never gave you aught.
OPHELIA:
My honour'd lord, you know right well you did;
And, with them, words of so sweet breath composed
As made the things more rich: their perfume lost,
Take these again; for to the noble mind
Rich gifts wax poor when givers prove unkind.
There, my lord.
لتنظيم مسافات سطر واحد، ضع المؤشر في بداية السطر واضغط على Tab. مع كل ضغطة، ستزيد المسافات بمقدار أربعة فراغات.
إذا قمت بزيادة المسافات أكثر من اللازم، اضغط على Shift+Tab.
إذا كنت تريد تنظيم مسافات عدة أسطر، فما عليك سوى تحديدها واضغط على Tab.
لإلغاء التغيير، اضغط على Shift+Tab.