python2.7专题

python2.7 的中文编码处理,解决UnicodeEncodeError: 'ascii' codec can't encode character 问题

python2.7 的中文编码处理 最近业务中需要用 Python 写一些脚本。尽管脚本的交互只是命令行 + 日志输出,但是为了让界面友好些,我还是决定用中文输出日志信息。 很快,我就遇到了异常: UnicodeEncodeError: 'ascii' codec can't encode characters in p

urllib与urllib2的学习总结(python2.7.X)

先啰嗦一句,我使用的版本是python2.7,没有使用3.X的原因是我觉得2.7的扩展比较多,且较之前的版本变化不大,使用顺手。3.X简直就是革命性的变化,用的蹩手。3.x的版本urllib与urllib2已经合并为一个urllib库,学着比较清晰些,2.7的版本呢urllib与urllib2各有各的作用,下面我把自己学习官方文档和其他资料的总结写下,方便以后使用。   urllib与url

Centos7下python2.7升级至3.6

服务器版本: centos7 旧python版本:2.7.5 新python版本:3.6.3 接下来正式开始: 从Python官网到获取Python3的包, 切换到目录/usr/local/src 执行命令行: wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz使用命令,如下命令进行解压缩:  tar -xzf Pyt

Deepin下Python2.7安装Django出现'module' object has no attribute 'lru_cache'错误

错误信息如下图 这里是解决方案 是Python与Django版本不匹配的问题。 使用pip命令“sudo pip install Django”下载的是Django2.0版本的压缩包,所以安装不成功; 改成下载Django1.9版本就OK了:sudo pip install Django==1.9 以下方案并不能解决问题!并不能! 以为是电脑抽了,重装Django或者

Python2.7下TypeError: Expected Ptr<cv::UMat> for argument ‘%s‘

记录下踩过的坑,Python3.8环境下没有这个问题。环境:Python=2.7,numpy=1.16.6,opencv-python=4.1.2.30,使用cv2.resize出现的问题。在某个程序中使用cv2.resize出现错误,写了如下的测试程序: import cv2import numpy as npx = np.random.randn(10,10)x = x.astype(

mac os PyCharm 切换python2.7 安装selenium Chromederver配置

PyCharm 安装完默认是python3 查看mac os默认python2安装路径 Last login: Sun Jul 15 18:41:16 on ttys000y50@Y50:~$pythonPython 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-

mac os安装selenium python2.7

mac os 自带Python 2.7.10 y50@Y50:~$sudo easy_install pipPassword:Searching for pipReading https://pypi.python.org/simple/pip/Best match: pip 10.0.1Downloading https://files.pythonhosted.org/packag

Window下配置python2.7+Django

今天因为某个项目需要在自己的电脑上配置Django服务器做测试用在安装过程中遇到了很多问题,我在这里做一个记录和分享 目标配置 安装项功能python2.7代码运行环境Django 1.9.5构建服务器pip安装python包文件setuptools安装过程中需要MySQLdbpython连接数据库的库 过程 安装python 从python官网下载 2.7.12 (2.7中最新的子版

Python2.7 -- 爬虫之百度贴吧

源码参考;https://cuiqingcai.com/993.html 使用python,写爬虫,知识含量满满 涉及: 调用URL模块正则表达式模块文件流读写模块 代码如下粘贴出来直接可以运行: # -*- coding:utf-8 -*-__author__ = 'GP'import urllibimport urllib2import re#处理页面标签类class To

Python2.7 -- 模块的使用

看下面的代码,相当于java类中,通过main方法启动,执行一个方法的逻辑。 # coding:utf-8import sysdef test():args = sys.argvif len(args) == 1:print 'Hello, world!'elif len(args) == 2:print 'Hello, %s!' % args[1]else:print 'Too many a

Python2.7 -- 装饰器模式(类似Java拦截器)

# coding:utf-8import functoolsdef log(func):def wrapper(*args, **kw):print 'call %s():' % func.__name__return func(*args, **kw)return wrapper# 高阶函数def log(text):def decorator(func):@functools.wraps(

Python2.7 -- 如何使用函数

函数使用和创建入门 # coding:utf-8def my_def():return '你调用我想干啥!!!!!'def my_pass():passdef my_return_more(x, y, z):return x, y, zprint '官网的函数参考:http://docs.python.org/2/library/functions.html#abs'print '函数的用法:%

Python2.7 -- 基本用法备忘

基础类型用法 # coding:utf-8print 'int type : %s' % 1print 'float type : %s' % 1.1print 'String type : %s' % 'OK'print 'boolean type : %s' % Trueprint 'and : %s' % True and Falseprint 'or type : %s' % T

ubuntu12.04-64bit 安装python2.7.6

第一步,先安装一些必要的库 sudo apt-get install python-devsudo apt-get install libffi-devsudo apt-get install libssl-devsudo apt-get install libxml2-devsudo apt-get install libxslt-devsudo apt-get install li

'module' object has no attribute 'MLPRegressor'问题解决(Python2.7)

'module' object has no attribute 'MLPRegressor'  如题,在做神经网络回归时,发现2.7下的sklearn包不是最新的0.18,而重新easy_install sklearn又不能更新,此时只需使用easy_install scikit-neuralnetwork 命令更新神经网络包, 会同时自动更新sklearn版本为0.18

串口调试工具(Python2.7+pyserial+Tkinter)(很好的Tkinter例子,代码层次结构等)

需要与串口设备进行通讯,那么一个调试工具是必须的。 根据我自己的需要,写了个简易版本的串口调试工具: 预览图: ====================== 项目结构: COM --SerialHelper.py UI --Adaptive.py --SerialTool.py --PyTkinter.py main.py ====================== COM文件夹 Seria

ubuntu16.04安装anaconda(python2.7 版本)

1.下载anaconda安装文件,官网速度较慢,建议清华开源软件镜像站下载: https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/ 2.用终端进入anaconda安装文件所在文件夹路径(cd xxx) 3. 在终端输入bash xxx(xxx为anaconda安装文件名 4. 不断按enter键是命令窗口显示的内容来到协议末尾,输入yes,然

Mac 切换默认python2.7为python3.9,ModuleNotFoundError: No module named ‘requests‘

vim ~/.bash_profile #python 默认3.9export PATH=/usr/local/Frameworks/Python.framework/Versions/3.9/bin:$PATHalias python="/usr/local/Frameworks/Python.framework/Versions/3.9/bin/python3.9"#python 添

在windows下Python2.7安装以及第三方库的安装方法_控控控-上ke控_新浪博客

最今一直忙于Python库的安装;发现用命令方式安装方法真的很麻烦,后来搜到了一个好的网站,在windows直接用exe安装就行了,真的是幸好找到这个地址: http://www.lfd.uci.edu/~gohlke/pythonlibs/ 这上面有很多python第三方包的二进制安装文件,包括32位和64位的各种常用版本的Python库。下载安装就ok了! 里面涵盖个

安装Python2.7其他必要库

网上找了半天,终于把要安装的资料找到了。其他的不怎么全,就自己再次总结一下写。          我自己安装的是python 2.7。所以以下的东东都是针对2.7的软件。          numpy :http://sourceforge.net/projects/numpy/files/NumPy/1.8.1/   下载下面的numpy-1.8.2-win32-superpa

解决Python2.7的UnicodeEncodeError: ‘ascii‘codec can’t encode异常错误

代码上面应该没有什么问题,Python使用的是版本2.7,但是在运行的时候出现了异常错误UnicodeEncodeError:UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-78: ordinal not in range(128) 貌似是因为编码问题:Unicode编码与ASCII编码的不兼容,其实

conda 低版本环境的安装pytorch0.2 python2.7

方法一、 pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl 方法二、 一般安装参照官网即可:http://pytorch.org/ 这里选择用pip方式安装: wget http://download.pytorch.org/whl/c

解决python2.7.9版本requests访问https的问题

本人在linux下搭建python项目时,刚好需要通过python中的requests.post()方式去获取微信的openid,但是一直报如上截图出现的错误,我用的python版本是2.7.9 TypeError: MaxRetryError("HTTPSConnectionPool(host='api.weixin.qq.com', port=443): Max retries exce

4.MAC平台Python的下载、安装(含Python2.7+Python3.12双版本环境变量配置)——《跟老吕学Python编程》

4.MAC平台Python的下载、安装(含Python2.7+Python3.12双版本环境变量配置)——《跟老吕学Python编程》)——跟老吕学Python编程 一、下载MAC版Python1.Python官网2.MAC版Python下载网址 二、在MAC安装Python1.在MAC安装Python2.阅读Python重要信息3.同意Python许可4.确认同意5.安装类型6.输入密码7

启用刷了dd-wrt的无线路由器asus-n13u-b1外置usb存储支持,安装python2.7

硬件版本华硕 N13U Rev B1root@n13u:/tmp/mnt/sda_part1# cat /proc/cpuinfo system type        : Ralink RT3052   id:1 rev:3processor        : 0cpu model        : MIPS 24KEc V4.12BogoMIPS        : 255.59CPUClock

opencv与darknet在python2.7下报错问题

opencv与darknet在python2.7下报错问题 在整ROS的时候默认运行python2.7,不知道有什么办法可以调,导致yolo跑不了,报如下错 Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported 解决方法是按如下顺序重新编