
Python
vstvr
这个作者很懒,什么都没留下…
展开
-
Python "AttributeError: module 'serial' has no attribute 'Serial'"的解决建议
许多人从网上找到串口代码后,直接安装了serial,无法运行,然后又安装pyserial,出现上述问题,本文给出解决建议。如果你是按上述情况操作的,即使卸载了serial也无济于事,必须将二者同时卸载,然后单独安装最新版本的pyserial库。pycharm的卸载方法:1. 左上角 file——settings2. 选中你想要删除的库,点击右上角的 “-...原创 2019-05-25 22:45:31 · 23982 阅读 · 10 评论 -
Python3 用类实现疏松向量(sparse vector)和稠密向量(dense vector)的运算
# -*- coding: utf-8 -*-"""------------------------------------------------- File Name: Expri5_Exercise2 Description : Author : Adminstrator date: 2019/5/28----------...原创 2019-05-31 11:30:02 · 1479 阅读 · 3 评论 -
Python3 统计txt单词数量并写入新文件(+标点符号的去除+写文件+统计排序)【基础】
# -*- coding: utf-8 -*-"""------------------------------------------------- File Name: Expri4_Exercise2 Description : Author : VSTVR date: 2019/5/13-----------------...原创 2019-05-31 11:38:49 · 1479 阅读 · 0 评论 -
Python3 单词翻译爬虫,基于request库
整理不易,如果本文帮助了您,请点个赞再走!! ->_<-来源于某大佬的博客,对其进行了简化,实现输入一个单词返回其翻译结果的基础功能。import requestsdef translate(word): url = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=ru...原创 2019-05-31 11:42:40 · 274 阅读 · 0 评论 -
Python3 分数类,运算,最大公因数(In this problem, we will write a class that ...)
整理不易,如果本文帮助了您,请点个赞再走!! ->_<-原题:In this problem, we will write a class that can represent rational numbers, i.e. fractionsp/q.(a) Create a class Rational which is initialized by two in...原创 2019-05-28 20:34:31 · 476 阅读 · 0 评论 -
python3用迭代器实现前n个素数的查找,Iterator
我们在判断一个数tempval是否是素数时,需要将其对0~tempval的数取模(%),这个过程可以用迭代器实现原题:Write an iterator that iterates over the first n prime numbers. Use this to print out thefirst 10,000 primes.def printfirstnprime...原创 2019-06-11 08:26:06 · 1010 阅读 · 0 评论 -
python3列表生成式题目,a list with elements
原题:Exercise 3: List comprehensionsLet i, j = 1 ,….., n(a) Generate a list with elements [i,j].(b) Generate a list with elements [i,j] with i < j(c) Generate a list with elements i + j with b...原创 2019-06-11 08:32:08 · 424 阅读 · 0 评论 -
python3利用列表生成式、lambda函数快速返回素数列表
原题:Exercise 2: Prime challengeWrite the function primes(n) that return a list with all prime numbers up to nUse lambda functions and list comprehensions.Try your best to complete it with as litt...原创 2019-06-11 09:00:53 · 1214 阅读 · 0 评论