亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? python for newbies.htm

?? 1000 HOWTOs for various needs [WINDOWS]
?? HTM
?? 第 1 頁 / 共 4 頁
字號:


<HTML><HEAD><TITLE>Python for Newbies</TITLE>

<!--Style from http://blacksun.box.sk/tutorials.htm :)-->

<STYLE type=text/css>A:active {

	TEXT-DECORATION: none

}

A:hover {

	TEXT-DECORATION: underline

}

A:link {

	TEXT-DECORATION: none

}

A:visited {

	TEXT-DECORATION: none

}

</STYLE>



</HEAD>

<BODY aLink=#ccff00 bgColor=#000000 link=#99ccff text=#cccccc 

vLink=#cc99ff><FONT face="Verdana, Arial, Helvetica, sans-serif"><A name=top>

<H1 align=center>Python for Newbies</H1></A>

<H2 align=center>by <A href="mailto:skinite@home.com">Pupp3tM</A>, a.k.a. David 

Borowitz</H2>

<H3>Table of Contents</H3>

<OL>

  <LI><A 

  href="#intro">Introduction</A> 



  <OL type=a>

    <LI><A 

    href="#whatis">What 

    is Python?</A> 

    <LI><A 

    href="#interp">The 

    Interpreter</A> </LI></OL>

  <LI><A 

  href="#first">Your 

  First Program</A> 

  <OL type=a>

    <LI><A 

    href="#hello">Hello, 

    World!</A> 

    <LI><A 

    href="#explain">Explanation</A> 

    </LI></OL>

  <LI><A 

  href="#varmath">Variables 

  and Math</A> 

  <OL type=a>

    <LI><A 

    href="#var">Variables: 

    Strings, Numbers, etc.</A> 

    <LI><A 

    href="#math">Math 

    and Operators</A> </LI></OL>

  <LI><A 

  href="#io">Input/Output</A> 



  <OL type=a>

    <LI><A 

    href="#print">Printing 

    information</A> 

    <LI><A 

    href="#user">Interacting 

    with the User</A> </LI></OL>

  <LI><A 

  href="#control">Program 

  Control</A> 

  <OL type=a>

    <LI><A 

    href="#if">What 

    If...</A> 

    <LI><A 

    href="#for">For 

    Ever...</A> 

    <LI><A 

    href="#while">While 

    We...and Others</A> </LI></OL>

  <LI><A 

  href="#inter">Intermediate 

  Python</A> 

  <OL type=a>

    <LI><A 

    href="#tuples">Tuples!</A> 



    <LI><A 

    href="#string">Strings 

    and Slice Indexing</A> 

    <LI><A 

    href="#fileio">File 

    I/O</A> </LI></OL>

  <LI><A 

  href="#mod">Modules</A> 



  <OL type=a>

    <LI><A 

    href="#mod1">Overview 

    and Importing</A> 

    <LI><A 

    href="#builtin">Builtin 

    Modules</A> 

    <LI><A 

    href="#yours">User-Defined 

    Modules and Functions</A> </LI></OL>

  <LI><A 

  href="#close">In 

  Closing</A> 

  <OL type=a>

    <LI><A 

    href="#perl">Why 

    Python is Better than Perl</A> 

    <LI><A 

    href="#ref">References</A> 

    </LI></OL></LI></OL>

<HR>



<H2 align=center><A name=intro>Introduction</A></H2>

<H3 align=center><A name=whatis>What is Python?</A></H3><BR>

<P>Python is, in short, a scripting language. It is similar in function to Perl, 

but to my knowledge is not nearly as popular. To fix that is part of the goal of 

this tutorial. It is a very high-level language that can perform complex tasks, 

but is surprisingly easy to learn. Many different add=ons (modules) are 

available to control everything from MP3s to windowing toolkits (Unix). I find 

Python to be a just plain <I>fun</I> language to program in, as it is very 

intuitive and suited to a variety of uses. </P>

<P>Python can be run on almost any platform, from 'nix to Windows. To get 

Python, first go to <A href="http://www.python.org/">Python.org</A>, and then 

download away! </P>

<P>This tutorial is geared towards people who have little experience with 

programming but know at least something. I make numerous references to languages 

like C and Perl, which are good to know, but you won't lose much if you just 

skip over them. </P>

<P>What's with the funky name, you ask? Some sort of carnivorous reptile? No, 

dear reader. Python's creators were (are) big Monty Python fans. The name comes 

from the BBC show "Monty Python's Flying Circus," and in the official docs, it 

says "Making references to Monty Python skits in documentation is not only 

allowed, it is encouraged." That said, I'm afraid I haven't seen all too many 

Monty Python movies so we'll go a little light on the references :) </P>

<P>So sit back, grab a Coke, <A href="http://www.python.org/download/">download 

Python</A>, and get ready to learn :) </P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H3 align=center><A name=interp>The Interpreter</A></H3><BR>

<P>Python is a scripted, i.e. interpreted, language. Unlike C, which has a 

compiler, we have in Python the...(drum roll please)...Python interpreter. Once 

you have Python correctly installed, in your Unix shell or Dos box type 'python' 

(Note: anytime I tell you to type something and put it in quotes, don't type the 

quotes. I'm sure you already figured this out, but...). If you've used perl or 

some other interpreted language before, you might notice something: there's a 

prompt (those three little "&gt;&gt;&gt;" things)! Not waiting for stdin or 

saying "Usage: python &lt;script-file&gt;"! That's right, Python has an 

<I>interactive mode</I>. In this mode, you can type any Python command and it 

will work just like you typed it from a script, with a few differences. Most 

importantly, if you type a variable of some sort or something that returns a 

value of some sort (except assignments), it will print the result automatically. 

Neat for trying stuff out (and learning!). Now type '1 + 1' at the prompt you 

should still be at. What do you see? 2! Now ain't that a powerful language: <PRE>&gt;&gt;&gt; 1 + 1

2

</PRE>You can do this with any kind of variable or math expression (see part <A 

href="#math">3b</A>) 

and get some output. Works with strings too: <PRE>&gt;&gt;&gt; "elp! I'm being oppressed"

"elp! I'm being oppressed"

</PRE>Note the bad Monty Python reference :). Anyway, that's all for the 

interpreter. Now we get into the meat of things. If at any point there's a 

sample script and you don't feel like creating a new file for it, feel free to 

type (or better yet copy &amp; paste) it into the interpreter, it should work 

the same. Wait, scratch that :). If I put something in a script, it most likely 

means you only get the effect from a script and it won't work in interactive 

mode. Sorry. 

<P></P>

<P>Wait! One note before we leave. To quit the interpreter, you can't do 

anything fancy like type 'quit'. For some reason (beats me), that doesn't work. 

You have to type Ctrl+D to quit (on Unix at least, haven't tested it on 

Windows). Anyway if you type 'quit' it'll say something like 'Use Ctrl-D (i.e. 

EOF) to exit.' so listen to that. </P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H2 align=center><A name=first>Your First Program</A></H2>

<H3 align=center><A name=hello>Hello, World!</A></H3><BR>Alright, if you've ever 

read a programming tutorial before you know they all have some sort of program 

that just prints "Hello, World!" or something on the screen. Unfortunately, this 

tutorial is no different. Alright, here goes: <PRE>#!/usr/bin/python

#You only need the above line for Unix; replace that with your path to python



hello = "Hello, World!"

print hello

</PRE>That's it! Put that in a text file, name it hello.py, run it, and we're 

good. On Unix you may have to 'chmod +x hello.py' to run it, or just type 

'python hello.py'. Windows, I'm pretty sure .py files are associated with the 

Python interpreter automatically. 

<P></P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H3 align=center><A name=explain>Explanation</A></H3><BR>"Wow," you may be 

saying, "that was easy." Indeed it was. Now, though, you probably only have some 

remote clue of what's going on. We'll take it line by line. <PRE>#!/usr/bin/python

</PRE>This line, like you should've read, is only needed for Unix users. It 

tells your shell where the python executable is so it can run the script. <PRE>#You only need the above line for Unix; replace that with your path to python

</PRE>A pretty useless line, you may think, but it illustrates an important 

point: comments! Any good programmer knows that you need comments in your code, 

so just put # and anything after that on that line is a comment and will be 

ignored by the interpreter. <PRE>hello = "Hello, World!"

</PRE>I didn't really need this line, but I thought a Hello, World! script with 

only one line is kinda lame, so I added it anyway. hello is a string variable, 

which we'll talk about later, and the = operator assigns "Hello, World!" as its 

value. I'm sure if you've programmed before you've seen all this. <PRE>print hello

</PRE>This last line, as you may well guess, prints the contents of hello. If 

you're a perl guy (or girl :), you need to know that if you're printing a 

variable you can't put the name of the variable in quotes. But that's not too 

inconvenient, as we should see later. 

<P></P>

<P>Alright! Our first program! Now just a note or two before we move on. First, 

you may notice that there's nothing on the end of any lines, no ; like in perl 

or C. That's one of the convenient features of Python. I think it's more 

intuitive because blocks (later dammit!) are determined by indenting and every 

statement has its own line...you may disagree I guess but you'll just have to 

get used to it. </P>

<P><FONT size=-2><A 

href="#top">Back 

to top</A></FONT></P>

<HR>



<H2 align=center><A name=varmath>Variables and Math</A></H2>

<H3 align=center><A name=var>Variables: Strings, Numbers, etc.</A></H3><BR>In 

Python, just like any other language worth its salt, there are a number of data 

types, Mainly, there are numbers (of arbitrary precision), strings, lists, and 

tuples. Tuples are more of an "advanced" variable type, kind of like lists, so I 

won't go into them here, but I'll touch on them a bit in the <A 

href="#inter">Intermediate 

Python</A> section. 

<P></P>

<P>Numbers. What can I say? Numbers are numbers. To assign them, just like you 

did with the string in Hello World!, just put the name of your variable, the = 

operator, and what you want it to be: <PRE>&gt;&gt;&gt; a = 5

&gt;&gt;&gt;

</PRE>A word on variable names: I'm not quite sure exactly how long Python 

allows them to be (should I know?), but as a general rule you shouldn't have 

names more than 20 or so characters. Like other languages, variable names must 

be all alphanumeric characters and underscores (_), but you <I>can</I> start 

names with underscores, unlike some languages. 

<P></P>

<P>Anyway, on to strings. Strings store, obviously, strings of characters. 

Nothing you haven't heard before. For strings, you can use either type of quotes 

("" or ''), but be sure you know which kind. If you want to use, say, an 

apostrophe inside a string, you need to make sure of some things. If the string 

has "" quotes, don't worry about it, just put your apostraph. If you were in '' 

quotes, though, you would need to escape the apostrophe. This is so the 

interpreter doesn't think the apostrophe, which is just like a quote, is the end 

of your string. To escape the apostrophe, just put a \ (backslash) in front of 

the quote. Try it! It's great: <PRE>&gt;&gt;&gt; "I'm Dave"

"I'm Dave"

&gt;&gt;&gt; 'Python\'s my favorite language'

"Python's my favorite language"

&gt;&gt;&gt; "\"I can't think of anything else to say!\" he said"

'"I can\'t think of anything else to say!" he said'

&gt;&gt;&gt; 'That's too bad'

      File "&lt;stdin&gt;", line 1

    'That's too bad'

          ^

SyntaxError: invalid syntax

</PRE>Note the last two examples. The first one illustrates escaping of the "" 

quotes and also this: If you have both types of quotes in a string, Python will 

default to one and escape the other. Don't worry; if you're printing this to the 

screen it won't show the \ character in your output. In the last example, that's 

what happens when you don't escape quotes. You may notice Python has a nice way 

of handling errors, but we won't go into that. 

<P></P>

<P>Speaking of escaping, here are a few more characters you can escape (if it 

says 'n' then you use '\n' to escape it): 

<UL>

  <LI>n - Prints a newline, i.e. starts a new line. 

  <LI>t - Horizontal tab 

  <LI>b - Backslash. Deletes the last character typed 

  <LI>a - System beep 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国在线观看| 国产精品国产自产拍高清av王其| 久久美女高清视频| 亚洲蜜桃精久久久久久久| 精品一区二区在线看| 欧美性极品少妇| 中文字幕国产一区| 激情综合色综合久久综合| 欧美三级电影精品| 亚洲欧洲制服丝袜| 成人涩涩免费视频| 久久久99久久| 国产一区二区三区国产| 欧美疯狂性受xxxxx喷水图片| 中文字幕一区av| 国产成人综合在线观看| 亚洲精品在线一区二区| 日韩精品欧美精品| 欧美美女直播网站| 亚洲综合一二三区| 91久久精品网| 一区二区三区在线免费视频| 99久久伊人精品| 国产精品丝袜在线| 波多野结衣一区二区三区| 久久美女高清视频| 国产成人一区在线| 国产午夜精品福利| 国产盗摄一区二区| 国产亚洲精品资源在线26u| 国产一区二区三区四区五区美女| 日韩欧美亚洲国产精品字幕久久久| 五月激情六月综合| 91精品国产综合久久国产大片 | 蜜臀av一区二区在线免费观看 | 91视视频在线直接观看在线看网页在线看| 国产网红主播福利一区二区| 国产一区二区三区视频在线播放| 精品久久久网站| 国产麻豆欧美日韩一区| 亚洲国产激情av| 99视频在线观看一区三区| 亚洲欧美偷拍三级| 欧美日韩精品欧美日韩精品一| 亚洲福利一区二区| 欧美电影一区二区三区| 久久99热国产| 国产婷婷色一区二区三区| 成人app在线| 一二三区精品福利视频| 在线不卡的av| 国产精品夜夜爽| 亚洲精品成a人| 在线成人免费视频| 国产精品白丝jk白祙喷水网站| 国产精品美女久久福利网站| 91国产成人在线| 老司机精品视频导航| 国产丝袜美腿一区二区三区| 92精品国产成人观看免费 | 国产真实乱对白精彩久久| 国产欧美精品国产国产专区 | 国产精品123区| 一区二区久久久| 日韩免费在线观看| 99久久精品免费精品国产| 午夜婷婷国产麻豆精品| 国产亚洲人成网站| 在线一区二区观看| 国产一区二区在线电影| 一区二区三区四区在线| 日韩精品在线一区二区| 欧美视频第二页| 国产成人高清视频| 日韩精品电影在线观看| 国产欧美一区二区三区在线老狼| 欧美亚洲图片小说| 国产福利视频一区二区三区| 天天综合色天天综合色h| 国产精品久久久久久久久晋中 | 26uuu精品一区二区| 在线观看视频一区二区欧美日韩| 极品少妇xxxx精品少妇偷拍| 亚洲自拍欧美精品| 国产精品欧美久久久久无广告| 欧美一级理论片| 在线亚洲欧美专区二区| 成人免费高清在线| 极品美女销魂一区二区三区| 无码av中文一区二区三区桃花岛| 中文字幕在线不卡一区| 久久精品视频一区二区三区| 日韩一级大片在线| 欧美日韩一区小说| 色婷婷综合久久久久中文一区二区| 国产很黄免费观看久久| 美女网站色91| 青青草91视频| 午夜一区二区三区视频| 亚洲一区二区欧美日韩| 中文字幕一区av| 中文字幕中文在线不卡住| 国产三级欧美三级日产三级99| 欧美一级高清大全免费观看| 欧美精品视频www在线观看| 一本色道久久综合亚洲aⅴ蜜桃| 国产夫妻精品视频| 国产精品18久久久久久久久久久久| 日韩电影一区二区三区四区| 天堂影院一区二区| 日韩精品电影在线观看| 三级在线观看一区二区| 日日夜夜免费精品| 美洲天堂一区二卡三卡四卡视频| 天堂久久一区二区三区| 日韩av电影免费观看高清完整版| 亚洲午夜久久久久久久久电影院 | 欧美电影一区二区| 欧美精品久久久久久久多人混战| 欧美日韩免费观看一区三区| 欧美色综合网站| 欧美巨大另类极品videosbest| 欧美日韩成人综合| 日韩一区二区电影| 精品精品欲导航| 久久久美女毛片| 国产精品美女久久久久久| 中文字幕一区二区三区色视频| 亚洲色图色小说| 亚洲一区二区三区四区在线 | 久久久久久久综合色一本| 欧美激情中文不卡| 亚洲精品免费播放| 日本麻豆一区二区三区视频| 韩国成人在线视频| 99视频在线观看一区三区| 91成人看片片| 国产精品久久精品日日| 亚洲免费在线视频| 日本不卡一区二区| 粉嫩13p一区二区三区| 在线观看av一区| 日韩精品影音先锋| 日韩理论片网站| 日韩高清一区二区| 成人av网站在线观看| 欧美午夜电影一区| 久久久久久日产精品| 一区二区三区四区蜜桃| 久久精品国产久精国产爱| 成人美女在线视频| 欧美人与性动xxxx| 国产欧美视频一区二区| 视频精品一区二区| av在线这里只有精品| 91麻豆精品91久久久久久清纯| 久久久影视传媒| 日日摸夜夜添夜夜添精品视频| 国产成人精品免费一区二区| 欧美日韩亚洲综合在线| 国产亚洲一本大道中文在线| 午夜欧美一区二区三区在线播放| 国产不卡免费视频| 欧美电影一区二区三区| 中文一区二区完整视频在线观看 | 国产精品一区二区在线观看不卡| 色综合久久久久网| 国产喂奶挤奶一区二区三区| 石原莉奈在线亚洲二区| 91麻豆123| 久久精品人人做人人综合| 午夜精品一区在线观看| 99久久精品国产一区二区三区| 欧美xxx久久| 日韩激情av在线| 精品污污网站免费看| 国产精品三级久久久久三级| 美女精品一区二区| 欧美日韩中文精品| 尤物av一区二区| av在线不卡网| 国产日韩亚洲欧美综合| 黑人巨大精品欧美黑白配亚洲| 欧美日韩国产一级片| 一区二区三区在线观看网站| 99久久久久久99| 国产精品美女久久久久aⅴ国产馆| 国内精品久久久久影院一蜜桃| 91超碰这里只有精品国产| 亚洲国产精品一区二区久久恐怖片| 99久久精品情趣| 国产精品福利影院| av午夜精品一区二区三区| 国产人久久人人人人爽| 国内精品久久久久影院色| 日韩欧美综合在线| 美国毛片一区二区| 26uuu欧美| 国产在线播放一区| 久久精品欧美一区二区三区不卡 |