📄 node3.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0061)http://www.honors.montana.edu/~jjc/easytut/easytut/node3.html -->
<!--Converted with LaTeX2HTML 99.2beta6 (1.42)original version by: Nikos Drakos, CBLU, University of Leeds* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>Intro</TITLE>
<META content=Intro name=description>
<META content=easytut name=keywords>
<META content=document name=resource-type>
<META content=global name=distribution>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
<META content=text/css http-equiv=Content-Style-Type><LINK
href="node3_files/easytut.css" rel=STYLESHEET><LINK href="node4.html"
rel=next><LINK href="node2.html" rel=previous><LINK href="easytut.html"
rel=up><LINK href="node4.html" rel=next></HEAD>
<BODY><!--Navigation Panel--><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node4.html"
name=tex2html164><IMG align=bottom alt=next border=0 height=24
src="node3_files/next.png" width=37></A> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/easytut.html"
name=tex2html160><IMG align=bottom alt=up border=0 height=24
src="node3_files/up.png" width=26></A> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html154><IMG align=bottom alt=previous border=0 height=24
src="node3_files/prev.png" width=63></A> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html162><IMG align=bottom alt=contents border=0 height=24
src="node3_files/contents.png" width=65></A> <BR><B>Next:</B> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node4.html"
name=tex2html165>Hello, World</A> <B>Up:</B> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/easytut.html"
name=tex2html161>Non-Programmers Tutorial For Python</A> <B>Previous:</B> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html155>Contents</A> <B><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html163>Contents</A></B> <BR><BR><!--End of Navigation Panel--><!--Table of Child-Links--><A
name=CHILD_LINKS><STRONG>Subsections</STRONG></A>
<UL>
<LI><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node3.html#SECTION00310000000000000000"
name=tex2html166>First things first</A>
<LI><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node3.html#SECTION00320000000000000000"
name=tex2html167>Installing Python</A>
<LI><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node3.html#SECTION00330000000000000000"
name=tex2html168>Interactive Mode</A>
<LI><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node3.html#SECTION00340000000000000000"
name=tex2html169>Creating and Running Programs</A>
<LI><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node3.html#SECTION00350000000000000000"
name=tex2html170>Using Python from the command line</A> </LI></UL><!--End of Table of Child-Links-->
<HR>
<H1><A name=SECTION00300000000000000000>Intro</A> </H1>
<P>
<H1><A name=SECTION00310000000000000000>First things first</A> </H1>
<P>So, you've never programmed before. As we go through this tutorial I will
attempt to teach you how to program. There really is only one way to learn to
program. <B>You</B> must read code and write code. I'm going to show you lots of
code. You should type in code that I show you to see what happens. Play around
with it and make changes. The worst that can happen is that it won't work. When
I type in code it will be formatted like this:
<P><PRE>##Python is easy to learn
print "Hello, World!"
</PRE>
<P>That's so it is easy to distinguish from the other text. To make it confusing
I will also print what the computer outputs in that same font.
<P>Now, on to more important things. In order to program in Python you need the
Python software. If you don't already have the Python software go to
http://www.python.org/download/ and get the proper version for your platform.
Download it, read the instructions and get it installed.
<P>
<H1><A name=SECTION00320000000000000000>Installing Python</A> </H1>First you
need to download the appropriate file for your computer from <TT><A
href="http://www.python.org/download"
name=tex2html1>http://www.python.org/download</A></TT>. Go to the 2.0 link (or
newer) and then get the windows installer if you use Windows or the rpm or
source if you use Unix.
<P>The Windows installer will download to file. The file can then be run by
double clicking on the icon that is downloaded. The installation will then
proceed.
<P>If you get the Unix source make sure you compile in the tk extension if you
want to use IDLE.
<P>
<H1><A name=SECTION00330000000000000000>Interactive Mode</A> </H1>Go into IDLE
(also called the Python GUI). You should see a window that has some text like
this: <PRE>Python 2.0 (#4, Dec 12 2000, 19:19:57)
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more information.
IDLE 0.6 -- press F1 for help
>>>
</PRE>The <CODE>>>></CODE> is Python way of telling you that you are in
interactive mode. In interactive mode what you type is immediately run. Try
typing <CODE>1+1</CODE> in. Python will respond with <CODE>2</CODE>. Interactive
mode allows you to test out and see what Python will do. If you ever feel you
need to play with new Python statements go into interactive mode and try them
out.
<P>
<H1><A name=SECTION00340000000000000000></A><A name=create></A><BR>Creating and
Running Programs </H1>Go into IDLE if you are not already. Go to
<CODE>File</CODE> then <CODE>New Window</CODE>. In this window type the
following: <PRE>print "Hello, World!"
</PRE>
<P>First save the program. Go to <CODE>File</CODE> then <CODE>Save</CODE>. Save
it as hello.py. (If you want you can save it to some other directory than the
default.) Now that it is saved it can be run.
<P>Next run the program by going to <CODE>Edit</CODE> then <CODE>Run
script</CODE>. This will output <CODE>Hello, World!</CODE> on the <CODE>*Python
Shell*</CODE> window.
<P>Confused still? Try this tutorial for IDLE at <TT><A
href="http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html"
name=tex2html2>http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html</A></TT>
<P>
<H1><A name=SECTION00350000000000000000>Using Python from the command line</A>
</H1>If you don't want to use Python from the command line, you don't have too,
just use IDLE. To get into interactive mode just type <CODE>python</CODE> with
out any arguments. To run a program create it with a text editor (Emacs has a
good python mode) and then run it with <CODE>python program name</CODE>.
<P>
<HR>
<!--Navigation Panel--><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node4.html"
name=tex2html164><IMG align=bottom alt=next border=0 height=24
src="node3_files/next.png" width=37></A> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/easytut.html"
name=tex2html160><IMG align=bottom alt=up border=0 height=24
src="node3_files/up.png" width=26></A> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html154><IMG align=bottom alt=previous border=0 height=24
src="node3_files/prev.png" width=63></A> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html162><IMG align=bottom alt=contents border=0 height=24
src="node3_files/contents.png" width=65></A> <BR><B>Next:</B> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node4.html"
name=tex2html165>Hello, World</A> <B>Up:</B> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/easytut.html"
name=tex2html161>Non-Programmers Tutorial For Python</A> <B>Previous:</B> <A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html155>Contents</A> <B><A
href="http://www.honors.montana.edu/~jjc/easytut/easytut/node2.html"
name=tex2html163>Contents</A></B> <!--End of Navigation Panel-->
<ADDRESS>Josh Cogliati <A
href="mailto:jjc@honors.montana.edu">jjc@honors.montana.edu</A>
</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -