
Python
gouxf_0219
这个作者很懒,什么都没留下…
展开
-
Python 中文乱码问题
py脚本开头加上:# -*- coding:utf-8 -*-cnstr就是你的中文字符串,做一下判断:如果是unicode,直接转码,如果不是,先解码再转码(解码前要知道你的字符串是什么编码)。if isinstance(cnstr, unicode): print tt.encode('utf-8')else: print cnstr.decode('cp936')...转载 2019-03-13 11:18:26 · 172 阅读 · 0 评论 -
python画小猪佩奇代码
from turtle import *def nose(x,y): #鼻子 penup() #提起笔 goto(x,y) #定位 pendown() #落笔,开始画 setheading(-30) #将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南) begin_fill() #准备开始填充图形 a=0.4 for i in r...原创 2018-07-02 12:28:17 · 10667 阅读 · 0 评论 -
Python 获取命令行输出
一、打印输出信息import osinfo = os.popen('YourCommand').readlines()for line in info: line = line.strip('\r\n') print(line)例如打印树莓派ip地址python中的os.system()和os.popen()区别python调用Shell脚本或者是调用系统命令,有两种方法...原创 2019-03-13 11:15:49 · 1300 阅读 · 0 评论 -
键盘上操作示例(枚举)
enum DRAW{ CMD_SHOW, CMD_FIX, CMD_CLEAR};DRAW _draw;_draw = CMD_FIX;switch (_draw){ case CMD_SHOW: printf("CMD_SHOW\n"); break; case CMD_FIX: printf("CMD_FIX\n"); break; case C...原创 2019-01-31 15:29:42 · 643 阅读 · 0 评论 -
python绘图:turtle画太极图
参考:https://www.jianshu.com/p/2a6fb8f38a16原理分解这个图形,图片中有四种颜色去心啊,每条曲线上的箭头表示乌龟移动的方向,首先从中心画一个半圆(红线),以红线所示圆的直径作半径画一个校园,半径为红线所示圆半径的0.15倍(蓝线),之所以选择0.15倍,是因为这样嵌入红圆内的小圆直径和红圆直径接近黄金分割。代码导入turtle库import tur...原创 2018-12-01 20:36:31 · 19072 阅读 · 12 评论 -
python GUI
GUI Programming先下载PySide库import turtleimport sysfrom PySide.QtCore import *from PySide.QtGui import *class TurtleControl(QWidget): def __init__(self, turtle): super(TurtleControl, s...转载 2018-12-01 20:34:20 · 165 阅读 · 0 评论 -
在同一电脑上同时安装python2和python3
https://www.cnblogs.com/zhengyihan1216/p/6011640.html转载 2018-11-08 14:37:51 · 169 阅读 · 0 评论 -
【错误】‘ascii ’ code can't encode characters in position 0-4: ordinal not in range(128)
解决办法:加入下面代码import sysreload(sys)sys.setdefaultencoding('utf8')原创 2019-04-19 13:52:39 · 362 阅读 · 0 评论