python
疏林玉露
这个作者很懒,什么都没留下…
展开
-
python list 换行分割
b='''abcdfs'''# print b.rstrip().split("\n")a = b.splitlines()print a# for i, val in enumerate(b):# print i, valprint len(a)结果如下:['a', 'b', 'c', 'd', 'f', 's']6[Finished in 0.1s原创 2014-07-17 14:16:08 · 20105 阅读 · 0 评论 -
python console 没有问题 pycharm import error
今天遇到这个问题,非常奇怪,肯定是因为pycharm 的路径设置错误,给解决方法放在这:首先在python console下:import sysprint sys.executable取得输入结果,比如我的为:/usr/local/opt/python/bin/python2.7然后打开pycharm -》File-》default setting-》Pro原创 2015-01-14 11:23:41 · 5247 阅读 · 0 评论 -
pep8 python编码规范中文版
PEP:8标题:Python编码建议版本:2132f8d8bcb4最后更新:2014-08-17 12:24:10 -0400 (Sun, 17 Aug 2014)作者:Guido van Rossum , Barry Warsaw , Nick Coghla原创 2014-08-27 14:21:12 · 6493 阅读 · 0 评论 -
python 列出文件目录下所有文件
使用Python自带的os.listdir函数,如果对这个函数不理解,请移步:https://docs.python.org/2/library/os.html#os.listdir我给封装了为两个函数:# -*- coding:utf-8 -*-from os import listdirfrom os.path import isfile, join# 列出文件,不包含文原创 2015-01-08 11:13:59 · 7529 阅读 · 0 评论 -
python Sphinx windows 安装
本文来自sphinx官网,翻译为中文,有错误的地方,希望大家指出,网址如下:http://sphinx-doc.org/latest/install.html总共分为三步1. 安装python(略)2. 安装easy_installPython有一个非常强大的easy_install命令行工具,利用这个工具,我们可以通过一行命令下载和安装第三方库。这是由“set原创 2014-08-27 17:35:08 · 4476 阅读 · 0 评论 -
python subprocess 启动程序出错
在使用python启动程序的时候,出现:很是奇怪。er原创 2014-08-19 15:57:30 · 2121 阅读 · 0 评论 -
Really Simple HTTP Server with Python
If you need a quick web server running and you don't want to mess with setting up apache or something similar, then Python can help. Python comes with a simple builtin HTTP server. With the help of转载 2014-07-14 10:45:10 · 637 阅读 · 0 评论 -
qt string qstring 解析
python中qstring 是以unicode编码的原创 2014-07-09 11:59:14 · 1282 阅读 · 0 评论 -
pyqt 通过notepad打开中文文件
这个问题真真纠结了两天原创 2014-07-09 19:50:35 · 1052 阅读 · 0 评论 -
python 获取当前时间
import timeISOTIMEFORMAT=’%Y-%m-%d %X’原创 2014-07-07 16:00:35 · 474 阅读 · 0 评论 -
纠结的Python2.7编码与os.walk()函数的目录参数
转载于:http://www.cnblogs.com/sumory/archive/2011/01/26/1945521.htmlPython3与Python2.x系列的编码处理(类型,文件等)有所不同,具体这里就不再介绍了,网上有很多相关文章。这里分享一个纠结了非常久的问题(因为一开始没特别注意函数参数的编码问题,所以浪费了不少时间,希望能给同样遇到这个问题的朋友们一点帮转载 2014-07-09 10:53:17 · 808 阅读 · 0 评论 -
python 中文问题
只需在头部添加上import sysreload(sys)sys.setdefaultencoding('utf-8')原创 2014-07-07 16:54:04 · 397 阅读 · 0 评论 -
pyqt 出现Attempting to add QLayout
采用qt绘制的界面出现原创 2014-07-07 18:55:52 · 1386 阅读 · 0 评论 -
Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not match any outer indentation level【解决过程】 1.对于此错误,最常见的原因是,的确没有对齐。但是我根据错误提示的行数,去代码中看了下,没啥问题啊。 都是用T原创 2014-07-04 16:16:26 · 51559 阅读 · 0 评论 -
python getOpenFileName 中文路径乱码问题
转载于http://xiaosu.blog.51cto.com/2914416/1340932原因是python2.7在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错,不过在python3就不会有这样的问题。临时解决方法:代码中加入如下三行import sys原创 2014-07-03 12:15:32 · 3397 阅读 · 0 评论 -
pip 更新 国内镜像站
pip 安装太缓慢,可以指定国内镜像站>pip install PIL --trusted-host http://pypi.douban.com/simple/原创 2016-11-18 14:56:00 · 1404 阅读 · 0 评论