This document provides an overview of web development in Python. It includes an example of a simple web application that connects to a MySQL database and displays the top 10 books ordered by publication date. It also lists some popular Python web development frameworks, including Django, Flask, and Pyramid, and provides references to their websites.
This document discusses various methods for reading and writing files in Python, including open(), read(), readline(), readlines(), write(), seek(), and tell(). It provides examples of opening files, reading the contents, writing new text, and changing the file position. The open() function is used to open a file and return a file object, which then has various methods that can be called to perform operations on the file.
This document provides an overview of the Python programming language. It begins by explaining what Python is - a general purpose, interpreted programming language that can be used as both a programming and scripting language. It then discusses the differences between programs and scripting languages. The history and creator of Python, Guido van Rossum, are outlined. The document explores the scope of Python and what tasks it can be used for. Popular companies and industries that use Python today are listed. Reasons why people use Python, such as it being free, powerful, and portable, are provided. Instructions for installing Python and running Python code are included. The document covers Python code execution and introduces basic Python concepts like variables, strings, data types, lists
The PyConTW (http://tw.pycon.org) organizer wishes to improve the quality and quantity of the programming cummunities in Taiwan. Though Python is their core tool and methodology, they know it's worth to learn and communicate with wide-ranging communities. Understanding cultures and ecosystem of a language takes me about three to six months. This six-hour course wraps up what I - an experienced Java developer - have learned from Python ecosystem and the agenda of the past PyConTW.
你可以在以下鏈結找到中文內容:
http://www.codedata.com.tw/python/python-tutorial-the-1st-class-1-preface
4. 2-4 Python 3.5 技術手冊
Welcome to Python 3.5's help utility!
If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/3.5/tutorial/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics". Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".
help>
這會進入 help()說明頁面,注意提示符號變成了 help>,在上頭這段文字
中有說明頁面的使用方式,像是想結束說明頁面,可以輸入 quit,想哪道有哪
些模組、關鍵字等,可以輸入 modules、keywords 等,例如來看看 Python 中有
哪些關鍵字:
help> keywords
Here is a list of the Python keywords. Enter any keyword to get more help.
False def if raise
None del import return
True elif in try
and else is while
as except lambda with
assert finally nonlocal yield
break for not
class from or
continue global pass
help>
剛才有使用過 print()函式,你會好奇它怎麼使用嗎?在說明頁面中輸入
print 就可以查詢了:
help> print
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
5. 第 2 章 從 REPL 到 IDE 2-5
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
help>
現在輸入 quit,回到 REPL 中,實際上,在 REPL 中也可以直接輸入
help(print)來查詢函式等說明:
help> quit
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)". Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
>>> help(print)
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='n', file=sys.stdout, flush=False)
...略
>>>
如果要離開 REPL 環境,可以執行 quit()函式。實際上,如果只是要執行
個小程式片段,又不想麻煩地進入 REPL,可以在使用 python 指令時加上-c 引
數,之後接上使用""包含的程式片段。例如:
>>> quit()
C:UsersJustin>python -c "print('Hello World')"
Hello World
C:UsersJustin>python -c "help(print)"
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='n', file=sys.stdout, flush=False)
...略
C:UsersJustin>
在 Python 官方網站 www.python.org 首頁,也提供了一個互動環境,臨時要
試個程式小片段,又不想要安裝 Python 或找個裝有 Python 的電腦時,開個瀏
覽器就可以使用囉!