问题1:SyntaxError: Non-ASCII character '\xe5' in file E:\PythonDev\testmodule.py on line 21, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
解答:程序中的编码错误,python默认是acii模式,没有支持utf8,代码的中文字符导致.源代码文件第一行添加:#coding:utf-8,这样就可以避免了
问题2:python输出时如何换行
解答:python 3.x 如print("Hello", end='')
python 2.x 如print("Hello"),
问题3:如何安装机器学习包
解答:安装机器学习包sklearn,可以用easy_install安装,或者到官网下载安装包,各种包存放的路径在Python27\Lib\site- packages
问题4:简易的Anaconda集成开发环境
下载Anaconda,集成了大量的工具包(这里的工具包可以拷贝到其它集成开发环境,如Aptana Studio 3),省掉了一个个安装,且互相依赖导致的麻烦事,并且还有ipython notebook基于web的命令交互工具。
问题5:datacaluate.py中编写以下代码时,报"....ImportError: No module named dateutil.tz..."
1 ''' 2 Created on 2015-1-16 3 4 @author: xuzhengzhu 5 ''' 6 import xlrd,openpyxl 7 import pandas as pd 8 file=pd.ExcelFile('e:\\report.xlsx') 9 data=file.parse('Sheet1') 10 x=data[['myjg','tjg']] 11 y=data['byjg']
Traceback (most recent call last):
File "E:\aptnadev\dataAnaly\dataCalulate.py", line 7, in <module>
import pandas as pd
File "C:\Python27\lib\site-packages\pandas\__init__.py", line 10, in <module>
import pandas.lib as lib
File "lib.pyx", line 1, in init pandas.lib (pandas\lib.c:74379)
File "tslib.pyx", line 37, in init pandas.tslib (pandas\tslib.c:63090)
ImportError: No module named dateutil.tz
No module named dateutil.tz
解答: 第一步:在https://pypi.python.org/pypi/python-dateutil 下载,下载时请下载文档类型type为"Source",
因为我下载的type为"Python Wheel",安装是报找不到"setup.py".
第二步:pip install [python-dateutil]
C:\Python27\Scripts>pip install E:\python-dateutil-2.4.0\python-dateutil-2.4.0
Unpacking e:\python-dateutil-2.4.0\python-dateutil-2.4.0
Running setup.py (path:c:\docume~1\xuzhen~1\locals~1\temp\pip-wqv6ra-build\setup.py) egg_info for package from file:///E:/python-dateutil-2.4.0/python-dateutil-2.4.0
Downloading/unpacking six>=1.5 (from python-dateutil==2.4.0)
Downloading six-1.9.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil
Running setup.py install for python-dateutil
Successfully installed six python-dateutil
Cleaning up...
C:\Python27\Scripts>