sixu05202004 / pythontutorial3 Goto Github PK
View Code? Open in Web Editor NEWpython 3.5.1 tutorial中文版
Home Page: http://www.pythondoc.com/pythontutorial3/index.html
python 3.5.1 tutorial中文版
Home Page: http://www.pythondoc.com/pythontutorial3/index.html
http://www.pythondoc.com/pythontutorial3/classes.html#tut-exceptionclasses
发生的异常其类型如果是 except 子句中列出的类,或者是其派生类,那么它们就是相符的(反过来说--发生的异常其类型如果是异常子句中列出的类的基类,它们就不相符)。例如,以下代码会按顺序打印 B,C,D:
英文原文:
A class in an except clause is compatible with an exception if it is the same class or a base class thereof (but not the other way around — an except clause listing a derived class is not compatible with a base class). For example, the following code will print B, C, D in that order:
应该基类 / 派生类互换位置,修改为
如果该异常是同样的类, 或是它的基类,那么异常类可以与该异常类相容, (相反 ,—— 一个 except 语句列出的派生类与其基类并不相容)比如就像下面代码一样,会依次打印出 B, C, D:
还是离线看文档比较方便。
找到个也是用Python写的rst2pdf但不怎么会用,担心生成的PDF效果不满意。
你好,
我用的是win10 win7 64bit python 3.6 版 本, 安装一个pywin32 模块,从:https://sourceforge.net/projects/pywin32/ pywin32-220.zip 和 pywin32-220.win-amd64-py3.6.exe 分别安装了,都 不成功。
pywin32-220.win-amd64-py3.6.exe提示注册表找不到路径。但我注册表内都有。
pywin32-220.zip 中运行setup3.py 来安装就提示:
============= RESTART: D:\360安全浏览器下载\BV流控\pywin32-220\setup3.py =============
Converting...
Executing...
Building pywin32 3.6.220.0
Traceback (most recent call last):
File "D:\360安全浏览器下载\BV流控\pywin32-220\setup3.py", line 16, in
exec(str(got))
File "", line 1944, in
File "", line 594, in init
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\ntpath.py", line 75, in join
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
请问, 这种情况,是模块哪个地方有问题,我是初学者,麻烦你解答一下。谢谢!
原文:For example, the module name A.B designates a submodule named B in a package named A.
来自:http://docs.python.org/3.2/tutorial/modules.html#packages
你的翻译是:例如,名为 A.B 的模块表示了名为 B 的包中名为 A 的子模块。
我觉得应该翻译为:例如, 名为A.B的模块,表示名为B的子模块,置于名为A的包中。
请参考。
Python3 标准库概览
下的互联网访问
urllib.request 给出的第一个例子执行报错,谷歌了好多找不到原因。
教程给出的例子:
>>> from urllib.request import urlopen
>>> for line in urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
... line = line.decode('utf-8') # Decoding the binary data to text.
... if 'EST' in line or 'EDT' in line: # look for Eastern Time
... print(line)
<BR>Nov. 25, 09:43:32 PM EST
执行报错信息:
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 936, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 722, in create_connection
raise err
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
TimeoutError: [Errno 60] Operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Yourname/Desktop/s3.py", line 2, in <module>
re = r.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1346, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 60] Operation timed out>
[Finished in 76.2s with exit code 1]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.