1.2 Running Python
One of the challenges of getting started with Python is that you might have to install
Python and related software on your computer. If you are familiar with your operating
system, and especially if you are comfortable with the command-line interface, you will
have no trouble installing Python. But for beginners, it can be painful to learn about system
administration and programming at the same time.
To avoid that problem, I recommend that you start out running Python in a browser. Later,
when you are comfortable with Python, I’ll make suggestions for installing Python on your
computer.
There are a number of web pages you can use to run Python. If you already have a favorite,
go ahead and use it. Otherwise I recommend PythonAnywhere. I provide detailed
instructions for getting started at http://tinyurl.com/thinkpython2e.
There are two versions of Python, called Python 2 and Python 3. They are very similar, so
if you learn one, it is easy to switch to the other. In fact, there are only a few differences you
will encounter as a beginner. This book is written for Python 3, but I include some notes
about Python 2.
The Python interpreter is a program that reads and executes Python code. Depending
on your environment, you might start the interpreter by clicking on an icon, or by typing
python on a command line. When it starts, you should see output like this:
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
The first three lines contain information about the interpreter and the operating system it’s
running on, so it might be different for you. But you should check that the version number,
which is 3.4.0 in this example, begins with 3, which indicates that you are running Python
3. If it begins with 2, you are running (you guessed it) Python 2.
The last line is a prompt that indicates that the interpreter is ready for you to enter code. If
you type a line of code and hit Enter, the interpreter displays the result:
>>> 1 + 1
2
Now you’re ready to get started. From here on, I assume that you know how to start the
Python interpreter and run code.
1.2 ใช้งูเหลือมหนึ่งในความท้าทายของการเริ่มต้นกับหลามคือ คุณอาจต้องติดตั้งงูหลามและซอฟต์แวร์ที่เกี่ยวข้องกับคอมพิวเตอร์ของคุณ ถ้าคุณคุ้นเคยกับงานของคุณระบบ และโดยเฉพาะอย่างยิ่งถ้าคุณมีความสะดวกสบายกับบรรทัดคำสั่งอินเตอร์เฟซ , คุณจะมีปัญหาการติดตั้ง Python . แต่สำหรับผู้เริ่มต้น มันสามารถจะเจ็บปวดเพื่อเรียนรู้เกี่ยวกับระบบและการบริหารโปรแกรมในเวลาเดียวกันเพื่อหลีกเลี่ยงปัญหาที่ ผมขอแนะนำให้คุณเริ่มออกวิ่งหนีงูในเบราว์เซอร์ ต่อมาเมื่อคุณมีความสะดวกสบายกับงู ผมจะให้คำแนะนำสำหรับการติดตั้ง Python บนของคุณคอมพิวเตอร์มีจำนวนของหน้าเว็บที่คุณสามารถใช้เพื่อหนีงูเหลือม หากคุณมีรายการโปรดไปข้างหน้าและใช้มัน ไม่งั้นผมแนะนำ pythonanywhere . ผมให้รายละเอียดคำแนะนำสำหรับการเริ่มต้นที่ http://tinyurl.com/thinkpython2e .มีรุ่นสองของงูเหลือม งูหลาม งูเหลือม เรียกว่า 2 3 พวกเขาจะคล้ายกันมากถ้าคุณได้เรียนรู้หนึ่ง , มันเป็นเรื่องง่ายที่จะเปลี่ยนไปอีก ในความเป็นจริงมีเพียงไม่กี่ความแตกต่างที่คุณจะพบเป็นมือใหม่ หนังสือเล่มนี้เขียนขึ้นสำหรับ Python 3 , แต่ฉันมีบางบันทึกเกี่ยวกับงูหลาม 2งูหลามล่ามเป็นโปรแกรมที่อ่านและรันรหัสหลาม . ทั้งนี้ในสภาพแวดล้อมของคุณ คุณอาจเริ่มต้นล่ามโดยคลิกที่ไอคอนหรือโดยการพิมพ์งูหลามบนบรรทัดคำสั่ง เมื่อเริ่มต้น คุณควรเห็นผลลัพธ์เช่นนี้งูหลาม 3.4.0 ( ค่าเริ่มต้น , จุน 19 ปี 2015 14:20:21 )[ GCC 4.8.2 ] บนลินุกซ์ประเภท " ช่วย " , " ลิขสิทธิ์ " , " เครดิต " หรือ " อนุญาต " สำหรับข้อมูลเพิ่มเติม> > >สามบรรทัดแรกประกอบด้วยข้อมูลเกี่ยวกับล่ามและระบบปฏิบัติการมันวิ่งบน มันอาจจะแตกต่างกันสำหรับคุณ แต่คุณควรตรวจสอบว่า รุ่นหมายเลขซึ่งเป็น 3.4.0 ในตัวอย่างนี้เริ่มต้นด้วย 3 ซึ่งบ่งชี้ว่า คุณกำลัง งูหลาม3 . ถ้ามันเริ่มต้นด้วย 2 , คุณจะวิ่ง ( คุณ guessed มัน ) งูเหลือม 2บรรทัดสุดท้ายคือการบ่งบอกว่าล่ามจะพร้อมสำหรับคุณที่จะป้อนรหัส ถ้าคุณพิมพ์บรรทัดของรหัสและกด Enter , ล่ามแสดงผล :> > > 1 + 12ตอนนี้คุณพร้อมที่จะเริ่มต้น จากที่นี่ ฉันสมมติว่าคุณรู้วิธีที่จะเริ่มต้นล่าม Python และรหัสเรียกใช้
การแปล กรุณารอสักครู่..
