同步阅读进度,多语言翻译,过滤屏幕蓝光,评论分享,更多完整功能,更好读书体验,试试 阅读 ‧ 电子书库
Packages and Search Path Settings
If you use this feature, keep in mind that the directory paths in your import statements can only be variables separated by periods. You cannot use any platform-specific path syntax in your import statements, such as C:\dir1, My Documents.dir2 or ../dir1—these do not work syntactically. Instead, use platform-specific syntax in your module search path settings to name the container directories.
For instance, in the prior example, dir0—the directory name you add to your module search path—can be an arbitrarily long and platform-specific directory path leading up to dir1. Instead of using an invalid statement like this:
import C:\mycode\dir1\dir2\mod # Error: illegal syntax
add C:\mycode to your PYTHONPATH variable or a .pth file (assuming it is not the program’s home directory, in which case this step is not necessary), and say this in your script:
import dir1.dir2.mod
In effect, entries on the module search path provide platform-specific directory path prefixes, which lead to the leftmost names in import statements. import statements provide directory path tails in a platform-neutral fashion.[52]
请支持我们,让我们可以支付服务器费用。
使用微信支付打赏
