![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
paulsweet_M
你不知道的事!
展开
-
conda vs pip vs virtualenv
原创 2016-07-23 18:17:54 · 377 阅读 · 0 评论 -
dict(待补充)
dicthelp(dict)Help on class dict in module __builtin__:class dict(object) | dict() -> new empty dictionary | dict(mapping) -> new dictionary initialized from a mapping object's | (key, value)原创 2016-08-26 22:57:32 · 469 阅读 · 0 评论 -
没那么简单:decode encode open
学习小甲鱼的python基础教程那么长时间,这中间也有许多深入的思考,有些看似平常的东西,经过深入思考发现原来没那么简单,为了巩固自己的理解,同鱼油交流,特地整理成系列帖子,中间有什么理解或表达有误的地方希望鱼油指正,共同提升。 今天探讨decode encode open 这些涉及到编码,解码的问题,讨论这个问题先要讨论一下编程的整个过程,编程过程为:转载 2016-08-24 22:56:17 · 371 阅读 · 0 评论 -
python中读写文件及中文编码处理方法【整理】
一、打开文件代码如下:>>> f =open("d:\test.txt", "w")说明:第一个参数是文件名称,包括路径;第二个参数是打开的模式mode :'r':只读(缺省。如果文件不存在,则抛出错误)'w':只写(如果文件不存在,则自动创建文件)'a':附加到文件末尾 'r+':读写如果需要以二进制方式打开文件,需要在mode后面加上字符"b",比如"r转载 2016-08-25 16:27:53 · 1414 阅读 · 0 评论 -
终端安装多版本python,Anaconda
主要参考文献:http://www.tuicool.com/articles/MBNrquE, http://www.cnblogs.com/micrari/p/5693652.html1.安装pyenv,使用 de >homebrewde> brew install pyenv2.查看pyenv可以安装的版本列表$ pyenv install --list3.安装指定的py原创 2016-07-23 18:17:50 · 417 阅读 · 0 评论 -
二,八,十,十六进制输入转换
Python中:2进制是以0b开头的: 例如: 0b11 则表示十进制的38进制是以0开头的: 例如: 011则表示十进制的9 16进制是以0x开头的: 例如: 0x11则表示十进制的17转换为2进制 bin()转换为8进制 oct()转换为10进制 int()转换为16进制hex()---------------------------------------------------------原创 2016-07-23 18:16:39 · 298 阅读 · 0 评论 -
*while计算用户输入的数字的总和
# whilesum.pyn = input('How many numbers to sum ?')total = 0i = 1while i n: s = raw_input('enter' + ' number' + str(i + 1) + ':') total = total + int(s) i = i + 1print('The sum is '+ str(tota原创 2016-07-23 18:16:28 · 819 阅读 · 0 评论 -
*for计算用户输入的数字的总和
#forsum.pyn = input('How many numbers to sum?')total = 0for i in range(n): s = raw_input('Enter number' + str(i + 1) + ':') total = total + int(s)print('The sum is ' + str(total))原创 2016-07-23 18:16:23 · 644 阅读 · 0 评论 -
*for计算阶乘
# forfact.pyn = input('Enter an integer >= 0 :')fact = 1for i in range(2,n+1): fact = fact * iprint(str(n) + ' factorial is ' + str(fact))原创 2016-07-23 18:16:16 · 354 阅读 · 0 评论 -
*while计算阶乘
# whilefact.pyn = input('Enter an integer >= 0:')fact = 1i = 2while i n: fact = fact * i i = i + 1print(str(n)+'factorial is' + str(fact))原创 2016-07-23 18:16:12 · 7460 阅读 · 1 评论 -
while语句
# while10.pyi = 0while i 10: print(i) i = i + 1原创 2016-07-23 18:16:09 · 183 阅读 · 0 评论 -
range函数
for i in range(0,10,1): print(i)momodeMacBook-Air:python momo$ python haha.py0123456789for i in range(10,0,-1): print(i)momodeMacBook-Air:python momo$ python haha.py10987654321注意:rang原创 2016-07-23 18:16:06 · 2160 阅读 · 0 评论 -
elif语句
#airfare.pyage = input('How old are you?')if age 2: print('free')elif 2age 13: print('child fare')else: print('adult fare')原创 2016-07-23 18:16:04 · 615 阅读 · 0 评论 -
Merry Christmas Eve
#password1.pypwd = raw_input('what is the password?')if pwd =='apple': print('Merry Christmas Eve!')else: print("You're a idiot!")print('Haha!')原创 2016-07-23 18:16:01 · 353 阅读 · 0 评论 -
input函数在py2和py3的区别
在python2中从控制台接收输入的方式有两种:input()和raw_input(),当输入为纯数字时input返回的是数值类型,如int,floatraw_inpout返回的是字符串类型,string类型输入字符串为表达式input会计算在字符串中的数字表达式,而raw_input不会。如输入 “57 + 3”,input会得到整数60,而raw_input会得到字符串”57 + 3”在pyt原创 2016-07-23 18:15:58 · 430 阅读 · 0 评论 -
导入模块,以模块math为例
方法1>>> import math>>> math.cos(1)0.5403023058681398方法2>>> from math import*运行后,调用函数不用再加math前缀,但如果函数与math模块中某个函数同名,将被math模块中的同名函数覆盖,不建议用这种方式>>> from math import sin,tan可以导入模块中的特定函数原创 2016-07-23 18:15:53 · 6122 阅读 · 0 评论 -
基本算术运算优先级(高到低)
1.乘方 ** 2.求余 %3.整除 //4.除法 /5.乘法 *6.减法 -7.加法 +原创 2016-07-23 18:15:50 · 3545 阅读 · 0 评论 -
退出python shell
>>>import sys >>>sys.exit()原创 2016-07-23 18:15:47 · 230 阅读 · 0 评论 -
数据科学的完整学习路径—Python版
从Python菜鸟到Python Kaggler的旅程(译注: Kaggle 是一个数据建模和数据分析竞赛平台)假如你想成为一个数据科学家,或者已经是数据科学家的你想扩展你的技能,那么你已经来对地方了。本文的目的就是给数据分析方面的Python新手提供一个完整的学习路径。该路径提供了你需要学习的利用Python进行数据分析的所有步骤的完整概述。如果你已经有一些相关的背景知识,或者你不需要路转载 2016-09-08 22:17:38 · 897 阅读 · 0 评论