Python入门
渣渣琪
菜鸟成长记
展开
-
windows情况下关于”python Jupyter不能导入外部,但是终端可以import“的问题的解决办法
感谢博客提供的方案,亲测有效。https://blog.csdn.net/qq_42182367/article/details/82594994问题解决!原创 2020-03-03 21:40:39 · 436 阅读 · 0 评论 -
apt-get安装问题:请尝试不指明软件包的名字来运行“apt-get -f install”
正在读取软件包列表... 完成正在分析软件包的依赖关系树... 完成您可能需要运行“apt-get -f install”来纠正下列错误:下列的软件包有不能满足的依赖关系:cdparanoia: 依赖: libcdparanoia0 (= 3a9.8-11) 但是,它将不会被安装gpdf: 依赖: libgnomeprint2.2-0 (>= 2.4.2) 但是,它将不会被安装依...原创 2019-11-18 16:21:10 · 695 阅读 · 0 评论 -
入坑codewars第16天-Transformation of a Number Through Prime Factorization
题目:Every natural number, n, may have a prime factorization like:We define the geometric derivative of n, as a number with the following value:For example: calculate the value of n* for n = 2...原创 2018-12-15 20:11:48 · 153 阅读 · 0 评论 -
入坑codewars第18天-Alphabet wars - nuclear strike
题目:Alphabet wars - nuclear strikeIntroductionThere is a war and nobody knows - the alphabet war!The letters hide in their nuclear shelters. The nuclear strikes hit the battlefield and killed a lo...原创 2018-12-20 17:17:31 · 286 阅读 · 0 评论 -
入坑codewars第15天-Regexp Basics - is it IPv4 address?
题目:Implement String#ipv4_address?, which should return true if given object is an IPv4 address - four numbers (0-255) separated by dots.It should only accept addresses in canonical representation,...原创 2018-12-14 15:31:01 · 183 阅读 · 0 评论 -
入坑codewars第十天-Product of consecutive Fib numbers、longest_palindrome
题目:The Fibonacci numbers are the numbers in the following integer sequence (Fn):0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...such asF(n) = F(n-1) + F(n-2) with F(0) = 0 and F...原创 2018-12-07 11:21:42 · 319 阅读 · 0 评论 -
入坑codewars第九天-Title Case
题目:Title CaseA string is considered to be in title case if each word in the string is either (a) capitalised (that is, only the first letter of the word is in upper case) or (b) considered to be a...原创 2018-12-06 21:18:30 · 430 阅读 · 0 评论 -
入坑codewars第14天-Where is my parent!?(cry)
题目:Mothers arranged dance party for children in school.On that party there are only mothers and their children.All are having great fun on dancing floor when suddenly all lights went out.Its dark ni...原创 2018-12-13 16:24:28 · 458 阅读 · 0 评论 -
入坑codewars第13天- Dashatize it
第一题:Given a number, return a string with dash'-'marks before and after each odd integer, but do not begin or end the string with a dash mark.Ex:dashatize(274) -> '2-7-4'dashatize(6815) ->...原创 2018-12-12 20:38:22 · 359 阅读 · 0 评论 -
入坑codewars第11天-Clock in Mirror
题目一:Peter can see a clock in the mirror from the place he sits in the office. When he saw the clock shows 12:22He knows that the time is 11:38in the same manner:05:25 --> 06:3501:50 -->...原创 2018-12-10 11:43:25 · 307 阅读 · 0 评论 -
入坑codewars第19天-Calculating with Functions
题目:This time we want to write calculations using functions and get the results. Let's have a look at some examples:JavaScript:seven(times(five())); // must return 35four(plus(nine())); // must...原创 2018-12-21 11:09:28 · 932 阅读 · 0 评论 -
入坑codewars第17天-Directions Reduction
题目:Once upon a time, on a way through the old wild west,…… a man was given directions to go from one point to another. The directions were "NORTH", "SOUTH", "WEST", "EAST". Clearly "NORTH" and "SO.原创 2018-12-16 14:04:21 · 745 阅读 · 2 评论 -
入坑codewars第12天-Best travel
题目一:John and Mary want to travel between a few towns A, B, C ... Mary has on a sheet of paper a list of distances between these towns. ls = [50, 55, 57, 58, 60]. John is tired of driving and he says...原创 2018-12-11 19:41:33 · 1234 阅读 · 0 评论 -
入坑codewars第20天- Rot13
题目:ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.Create a function that takes a ...原创 2018-12-25 11:31:03 · 558 阅读 · 0 评论 -
电视剧《知否知否,应是绿肥红瘦》——剧评词云制作
前几天看了一下csdn微信公众号发的关于知否剧评的词云制作觉得很有趣,因此也模仿了一下十分有趣,可是还有些细节要注意。第一步代码如下:# -*-coding:utf-8-*-#导入相关模块import requestsfrom lxml import etreeimport jiebaimport time#载入浏览器请求头,避免被检测header = { "U...原创 2019-02-14 22:00:10 · 684 阅读 · 0 评论 -
入坑codewars第21天-Numbers that are a power of their sum of digits
新年第一道题,已经几个月没写了,哎,毕业设计整不出The number 81 has a special property, a certain power of the sum of its digits is equal to 81 (nine squared). Eighty one (81), is the first number in having this property (n...原创 2019-02-09 23:09:44 · 370 阅读 · 0 评论 -
The Primes as a Result of the Longest Consecutive Sum I
好久没写codewars,哎,颓废了好多天。今天一写一题就是一天最后还是timeout,尴尬至极,但是至少输出答案都能对,需要优化代码。题目:https://www.codewars.com/kata/the-primes-as-a-result-of-the-longest-consecutive-sum-i/train/pythonThe Primes as a Result...原创 2019-07-22 19:52:35 · 184 阅读 · 0 评论 -
Pytorch快速搭建神经网络
(一)init和forward每一个torch模块当中都有__init__()和forward()__init__()里面包含搭建神经网络那些层所需要的信息;forward()包含神经网络前向传递的内容;比如init里面的那些层的组合就是由forward来完成;(二)要继承父类的__init__()(三)搭建层其中对于hidden:n_features是输入;n_h...原创 2019-08-01 13:55:45 · 368 阅读 · 0 评论 -
入坑codewars第八天-Help the bookseller !
今天只写了一道题不容易呀,实在不懂输出格式,于是想办法凑出来的……题目:A bookseller has lots of books classified in 26 categories labeled A, B, ... Z. Each book has a code c of 3, 4, 5 or more capitals letters. The 1st letter of a ...原创 2018-12-05 21:10:49 · 435 阅读 · 0 评论 -
入坑codewars第七天-Maximum subarray sum、Are they the “same”?
题目:题意:求连续子序列的和的最大值 思路:笨方法一个一个求:首先求第一个数分别加后面的数取一个最大值然后下一个数分别加后面的数取最大值以此类推……代码如下:def maxSequence(arr): maxsum=0 for i in range(0,len(arr)): sum1=0 for j in range...原创 2018-11-28 11:44:58 · 417 阅读 · 0 评论 -
(二)Python 2.7.15 shell 运行文件
一、创建文件二、输入语句三、保存到桌面为helloworld.py四、运行运行成功:原创 2018-07-16 17:41:55 · 1383 阅读 · 0 评论 -
(三)Python数据类型
一、整数十六进制前面加个‘0x’前缀即可。例子:二、浮点数1.23e9=1.23*10^9;1.2e-5=0.000012三、字符串例子:四、布尔类型例子:五、空值...原创 2018-07-19 07:52:13 · 129 阅读 · 0 评论 -
(四)python输出
一、简单输出二、‘,’的输出作用任务练习:或者去python官网下载python2.7版本,双击IDLE即可编写python代码:原创 2018-07-19 14:27:44 · 143 阅读 · 0 评论 -
(五) Python中定义字符串
一、字符串中只包含‘ ’;只需要用“ ”括起来就好。二、字符串中只包含“ ”,只需要用‘ ’ 括起来。三、字符串中又包含“ ”、‘ ’,则需要用转义字符 \ 。任务:...原创 2018-07-19 17:50:16 · 266 阅读 · 0 评论 -
基础练习-python数据结构习题
##习题1:列表a = [11,22,24,29,30,32]1 把28插入到列表的末端a.append(28)2 在元素29后面插入元素57a.insert(4,57)3 把元素11修改成6a[0]=63 删除元素32a.remove(32)4 对列表从小到大排序a.sort()##习题2:列表b = [1,2,3,4,5]1 用2种方法输出...原创 2018-10-17 11:59:18 · 2316 阅读 · 0 评论 -
对于TensorFlow+Keras深度学习人工智能实践应用中“NameError: name 'x_train_image' is not defined”的问题解决
首先出现问题:我一开始一直以为是我keras装错了,所以这里一直报错。后来仔细检查了发现不是。按照书上第58面打的代码,读取了MNIST数据然后执行:发现报错:因为是新手,在网上搜了半天,没找到原因,后来发现原来是书上大小写不统一,python是严格区分大小写的改完之后就成功了。...原创 2018-10-22 13:00:27 · 10434 阅读 · 3 评论 -
基础篇-python循环语句for,while习题练习
今天习题:习题一:1 用while语句的2种方法输出数字:1到10(1)x = 1while x <= 10: print(x) x += 1(2)word = [1,2,3,4,5,6,7,8,9,10]for x in word: print(x)(3)for y in range(1,10): print(y,end=' ')...原创 2018-10-22 16:15:18 · 3544 阅读 · 0 评论 -
python-关于字典排序问题的相关求解
题目:d = {'数学':98,'语文':89,'英语':79}(一)排序方法一:1.取d.keys(),d.values()2.sorted(zip(d.values(),d.keys()))#利用高阶函数把数据变成(值,键)的元组形式(默认从小到大排序)若要从大到小排序:sorted(zip(d.values(),d.keys()),reverse=True)#...原创 2018-10-17 20:26:38 · 189 阅读 · 0 评论 -
在Linux Ubuntu16.04中安装Tensorflow与keras
1、首先快捷键ctrl+Alt+t打开终端界面,输入python,一般都是python2.7,然后输入exit(0)退出;这里安装python3.5sudo apt-get install python3.5sudo rm /usr/bin/pythonsudo ln -s /usr/bin/python3.5 /usr/bin/python2、安装Anaconda(python3...原创 2018-10-25 18:12:01 · 3015 阅读 · 0 评论 -
jupyter(旧比特)常用快捷键
一、运行单元Shift+Enter二、切换至命令模式,即非编辑模式(编辑模式就是可以写代码的状态)Esc三、退出编辑模式即可各种操作1、按M键切换到markdown文本模式2、按Y键切换回code模式3、按a在当前命令行前加空命令行,按b在当前命令行后加空命令行a:b:4、在命令模式下连按两次D,可删除当前行5、按Tab键可以自动填充一些代码...原创 2018-11-09 17:01:30 · 215 阅读 · 0 评论 -
入坑codewars第一天-Invert values、String repeat、List Filtering
今天导师给开了会让我们每天在codewars上至少刷两道题,提高自己的python编程能力。不刷不知道一刷吓一跳。果然自己的编程能力很菜。实践出真知。一、题目题目说明:就是将列表中所有的取反,题目很简单,但是我不太会运用python代码二、求解就是一个for循环,利用了python代码独有的列表推导[-i for i in lst]意思是lst列表中所有数取反。虽然我知道有...原创 2018-11-22 12:38:00 · 287 阅读 · 0 评论 -
入坑codewars第三天-Build a pile of Cubes、Convert boolean values to strings 'Yes' or 'No'、Build Tower
第一题:Build a pile of Cubes:Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of n^3, the cube above will have volume of (n-1)^3 and so ...原创 2018-11-24 10:34:55 · 591 阅读 · 0 评论 -
入坑codewars第二天-Basic Mathematical Operations、Ones and Zeros
一、题目需要实现 +对应加法需要实现 -对应减法……以此类推二、求解简单的if语句二、题二题意就是:将列表中的数字看成一串二进制然后转成十进制数我的思路是:先把列表颠倒,这里注意列表a,a.reverse()就直接把a颠倒了;因为二进制是从右到左读,因此我先颠倒从左往右方便计算。(1)先颠倒列表:(2)循环用列表数字乘以2^n(...原创 2018-11-23 08:50:29 · 318 阅读 · 0 评论 -
入坑codewars第四天-Delete occurrences of an element if it occurs more than n times、Sum of odd numbers
第一题:Enough is enough!Alice and Bob were on a holiday. Both of them took many pictures of the places they've been, and now they want to show Charlie their entire collection. However, Charlie doesn'...原创 2018-11-25 11:59:59 · 429 阅读 · 0 评论 -
入坑codewars第五天-Dubstep、Regex validate PIN code
第一题:题目:Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes ...原创 2018-11-26 13:27:38 · 378 阅读 · 0 评论 -
入坑codewars第六天-Highest Scoring Word、The Supermarket Queue
题目:Given a string of words, you need to find the highest scoring word.Each letter of a word scores points according to it's position in the alphabet: a = 1, b = 2, c = 3 etc.You need to return t...原创 2018-11-27 19:20:25 · 714 阅读 · 0 评论