[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
The urllib module package gives us a file-like interface to the server’s reply for a URL. Notice that the output we read from th ...
Escaping text like this isn’t always required, but it is a good rule of thumb when its content isn’t known; scripts that generat ...
To handle form (and other) requests, Example 1-34 implements a Python CGI script that fetches and updates our shelve’s reco ...
replyhtml = replyhtml.replace('$ROWS$', rowshtml) def htmlize(adict): new = adict.copy() for field in fieldnames: # values may h ...
Directories, string formatting, and security A few fine points before we move on. First of all, make sure the web server script ...
In the interest of fairness, I should point out that Python’s newer str.format method could achieve much the same effect as the ...
As we’ve seen, such a URL can be submitted either within your browser or by scripts that use tools such as the urllib package. A ...
Finally, adding a record works the same as in the GUI: fill in a new key and field values and click Update; the CGI script creat ...
Except for automated tools, though, typing such a long URL will be noticeably more difficult than filling out the input page. He ...
>>> db['guido'].job 'BDFL' >>> list(db['guido'].name) ['G', 'v', 'R'] >>> list(db.keys()) ['sue', 'bi ...
In fact, we might avoid hardcoding HTML in our script completely if we use one of the HTML generator tools we’ll meet later, in ...
The Python “Secret Handshake” I’ve been involved with Python for some 18 years now as of this writing in 2010, and I have seen i ...
PART II System Programming This first in-depth part of the book presents Python’s system programming tools— interfaces to servic ...
...
CHAPTER 2 System Tools “The os.path to Knowledge” This chapter begins our in-depth look at ways to apply Python to real programm ...
maintained, and reused. When using Python, there is no need to start every new script from scratch. Moreover, we’ll find that Py ...
In fact, the standard library is so powerful that it is not uncommon to hear Python described as batteries included—a phrase gen ...
>>> len(dir(os)) # 122 on Windows, more on Unix 122 >>> len(dir(os.path)) # a nested module within os 52 The c ...
framework) can be arguably lumped into the systems domain as well. In addition, some built-in functions are actually system inte ...
'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions', 'winver'] The dir function simp ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf