Python的http.server(或Python的SimpleHTTPServer)是从命令行提供当前目录内容的好方法:
python -m http.server
Run Code Online (Sandbox Code Playgroud)
但是,就网络服务器而言,它非常低调......
它表现得好像是单线程的,并且在使用RequireJS加载JavaScript AMD模块时偶尔会导致超时错误.加载一个没有图像的简单页面可能需要五到十秒钟.
什么是更快的替代方案,同样方便?
在所有编程语言(我至少使用过)中,必须先打开文件才能读取或写入文件.
但这种开放式操作实际上做了什么?
典型功能的手册页实际上并没有告诉你除了"打开读/写文件"以外的任何内容:
http://www.cplusplus.com/reference/cstdio/fopen/
https://docs.python.org/3/library/functions.html#open
显然,通过使用该函数,您可以告诉它涉及创建某种有助于访问文件的对象.
另外一种方法是,如果我要实现一个open函数,它需要在Linux上做什么?
我使用IPython笔记本,并希望能够选择在IPython中创建2.x或3.x python笔记本.
我最初有Anaconda.使用Anaconda时,必须更改全局环境变量以选择所需的python版本,然后才能启动IPython.这不是我想要的,所以我卸载了Anaconda,现在已经使用MacPorts和PiP设置了我自己的安装.看来我还是要用
port select --set python <python version>
Run Code Online (Sandbox Code Playgroud)
在python 2.x和3.x之间切换.这并不比蟒蛇解决方案好.
有没有办法在启动IPython笔记本后选择要使用的python版本,最好是使用我当前的MacPorts构建?
当我打开一个Jupyter笔记本(以前称为IPython)时,默认为C:\Users\USERNAME.
如何将其更改为其他位置?
谢谢.
我正在编写一个脚本来检查用户目录中文件的权限,如果它们不被接受,我会警告它们,但我想检查不仅是登录用户的权限,还要检查组和其他人的权限.我怎样才能做到这一点?在我看来,os.access()在Python中只能检查运行脚本的用户的权限.
(Mac OSX 10.10.5)
我可以从matplotlib网站复制http://matplotlib.org/gallery.html#mplot3d的3D散点图示例代码http://matplotlib.org/examples/mplot3d/scatter3d_demo.html,但情节呈现为静态图像.我无法点击图表并动态旋转以查看3D绘图数据.
我使用示例代码实现了静态3D绘图 - 使用(a)终端内的ipython,(b)终端内的ipython笔记本,以及(c)从Anaconda启动器启动的ipython笔记本.
我想我错过了一些非常基本的步骤作为假设的知识.
在过去的学习中,plotting已经打开了一个GUI Python App,它有一个图形查看器.(下面显示的代码中的解决方案2打开了这个.)也许我需要知道将输出图导出到该显示方法的代码?(是的,使用%matplotlib(仅)作为没有内联或笔记本的第一行,如下面代码块中的注释所示.)
作为ipython笔记本中的一个例子:
# These lines are comments
# Initial setup from an online python notebook tutorial is below.
# Note the first line "%matplotlib inline" this is how the tutorial has it.
# Two solutions 1. use: "%matplotlib notebook" graphs appear dynamic in the notebook.
# 2. use: "%matplotlib" (only) graphs appear dynamic in separate window.
# ( 2. is the best solution for detailed graphs/plots. …Run Code Online (Sandbox Code Playgroud) 我想和Jupyter笔记本一起工作,但是在进行基本导入时遇到了困难(例如导入matplotlib).我想这是因为我有几个用户管理的python安装.例如:
> which -a python
/usr/bin/python
/usr/local/bin/python
> which -a ipython
/Library/Frameworks/Python.framework/Versions/3.5/bin/ipython
/usr/local/bin/ipython
> which -a jupyter
/Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter
/usr/local/bin/jupyter
Run Code Online (Sandbox Code Playgroud)
我曾经有过anaconda,但是从〜/ anaconda目录中删除了.现在,当我启动一个Jupyter笔记本时,我得到一个内核错误:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/pytho?n3.5/subprocess.py",
line 947, in init restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/pytho?n3.5/subprocess.py",
line 1551, in _execute_child raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2]
No such file or directory: '/Users/npr1/anaconda/envs/py27/bin/python'
Run Code Online (Sandbox Code Playgroud)
我该怎么办?!
我在 macOS 中将 IPython 与 iterm2 一起使用。我以前从未遇到过配色方案的问题,但这次出现异常时,它会突出显示颜色组合中的某些部分,我发现这些部分很难阅读。我尝试过在 iterm 中使用不同的颜色设置,并在文件中进行调整highlighting_style,colors但ipython_config.py运气不佳。我已经看到有一个选项可以设置特定的颜色highlighting_style_overrides,但我没有幸运地找到合适的 pygments 选项。
见Position下文。这是我所实现的最佳对比度设置,但我仍然发现在不聚焦的情况下很难阅读。
ipython ×6
python ×4
jupyter ×3
matplotlib ×2
plot ×2
c ×1
command-line ×1
httpserver ×1
linux ×1
macos ×1
pandas ×1
python-2.7 ×1
python-3.x ×1