随笔分类 -  python

摘要:win移植linux python执行shell脚本 os.system("command") os.popen("command") os.popen() 返回的是一个文件对象 subprocess.call() print(subprocess.call(["ls","-l"],shell=Fa 阅读全文
posted @ 2020-07-29 18:06 friedCoder 阅读(168) 评论(0) 推荐(0) 编辑
摘要:iterable 与 iterator range returns an iterable, not an iterator. To get an iterator, you need to call iter() >>> x = range(20) >>> next(x) TypeError: ' 阅读全文
posted @ 2020-07-29 17:18 friedCoder 阅读(112) 评论(0) 推荐(0) 编辑
摘要:anaconda winerror 127找不到指定的程序 现象**:conda install package 时,报错 winerror 127找不到指定的程序。 环境:win 10 + anaconda 4.8.0 / python 3.7。 解决(亲测):参考帖子https://github 阅读全文
posted @ 2020-07-29 10:07 friedCoder 阅读(264) 评论(0) 推荐(0) 编辑
摘要:type isinstance() 与 type() 区别: type() 不会认为子类是一种父类类型,不考虑继承关系。 isinstance() 会认为子类是一种父类类型,考虑继承关系。 如果要判断两个类型是否相同推荐使用 isinstance()。 class A: pass class B(A 阅读全文
posted @ 2020-07-23 09:35 friedCoder 阅读(217) 评论(0) 推荐(0) 编辑
摘要:json是用来将 各种类型 与 字符类型 进行相互转换 为什么要将数据保存为字符串的样子呢?这主要是为了将其保存在文件中,一来节省存储空间,保存方便;二来数据统一以字符串形式保存,增强了数据可移植性。 loads和dumps都不能直接操作文件类型,因此需要将数据read和write。 而load和d 阅读全文
posted @ 2020-05-01 18:30 friedCoder 阅读(146) 评论(0) 推荐(0) 编辑
摘要:python输出的方式和C语言有比较大的区别 # 方式1 i = 1 print( "%d", i ) #输出元组("%d", 1) 而不是 数字1 # 方式2 print( "你好", i ) #不输出('你好',1) 而是输出 ('\xe4\xbd\xa0\xe5\xa5\xbd', 1) # 阅读全文
posted @ 2020-05-01 06:19 friedCoder 阅读(181) 评论(0) 推荐(0) 编辑
摘要:编码问题 问题1 python采用 utf 8编码 通过 cmd命令 执行,报错 解决办法 设置窗口字符集: chcp 65001 set PYTHONIOENCODING=utf 8 问题2 python2的默认编码是ascII ,而代码中可能由utf 8的字符导致 解决办法 设置utf 8编码 阅读全文
posted @ 2020-05-01 06:17 friedCoder 阅读(1715) 评论(0) 推荐(0) 编辑
摘要:主要用到的库有 和`pymysql`, 注意pymysql不支持python3 篇幅有限,只针对主要操作进行说明 连接数据库 首先pymysql需要连接数据库,我这里连接的是本地数据库(数据库叫lds714610)。 从excel中读取数据 导入数据之前,需要先读取excel中的数据。 通过xlrd 阅读全文
posted @ 2020-05-01 06:13 friedCoder 阅读(1589) 评论(0) 推荐(1) 编辑
摘要:python2 和 python3 的except子句语法不同 Python2默认ascII编码,不支持中文 一般在程序的开头加上 coding:utf 8 来解决这个问题,但是在用open()方法打开文件时,中文名字却显示成了乱码。 open(filename, 'w')这个方法中,filenam 阅读全文
posted @ 2020-04-27 09:28 friedCoder 阅读(147) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/weixin_41481113/article/details/88410973 阅读全文
posted @ 2020-04-27 09:24 friedCoder 阅读(247) 评论(0) 推荐(0) 编辑
摘要:安装的时候会提示安装地址,我的是environment location: C:\Program1\Anaconda3\envs\py27 阅读全文
posted @ 2020-04-27 06:35 friedCoder 阅读(607) 评论(0) 推荐(0) 编辑
摘要:进入python交互界面 比如:python3.6 输入import platform 再输入platform.architecture() 阅读全文
posted @ 2020-04-27 06:29 friedCoder 阅读(387) 评论(0) 推荐(0) 编辑
摘要:typing 关于类型注释 decimal 关于精度更高的运算 itertools 关于一系列不同的生成器。如itertools.tee csv csv文件处理迭代器 collections 实现了特定目标的容器,以提供Python标准内建容器 dict , list , set , 和 tuple 阅读全文
posted @ 2020-04-18 09:26 friedCoder 阅读(114) 评论(0) 推荐(0) 编辑
摘要:yield from 先说说3个东西,可迭代iterable,迭代器iterator,生成器generator,3者关系层层递进。 iterable : \__iter__ (支持for循环) iterator : \__iter__ \_\_next__ (支持for循环、next) genera 阅读全文
posted @ 2020-04-17 17:56 friedCoder 阅读(140) 评论(0) 推荐(0) 编辑
摘要:参考 https://q.cnblogs.com/q/113067/ https://superuser.com/questions/1319047/cant install virtual interpreter in pycharm in linux 阅读全文
posted @ 2020-04-17 17:08 friedCoder 阅读(375) 评论(0) 推荐(0) 编辑
摘要:mypy 静态类型检查可以帮助coder在运行前(编译期)发现由于类型错误带来的bug 在开发的项目越来越大的时候,不必阅读更多的代码来确定你要修改的某个方法是否会影响其他的代码的运行 使用方法:(先安装) 类型:https://docs.python.org/zh cn/3/library/typ 阅读全文
posted @ 2020-04-17 17:05 friedCoder 阅读(182) 评论(0) 推荐(0) 编辑
摘要:转:https://blog.csdn.net/dqchouyang/article/details/47153201 软件源不同 pip用来安装来自PyPI(https://www.python.org/)的python所有的依赖包,并且可以选择安装任何在PyPI上已上传的先前版本的依赖包,个人认 阅读全文
posted @ 2020-04-17 17:01 friedCoder 阅读(249) 评论(0) 推荐(0) 编辑
摘要:用法记录: 更多参考:https://www.cnblogs.com/Uncle Guang/p/8796507.html 阅读全文
posted @ 2020-04-17 05:46 friedCoder 阅读(92) 评论(0) 推荐(0) 编辑
摘要:参考:https://blog.csdn.net/windscloud/article/details/79732014 python的del不同于C的free和C++的delete。 由于python都是引用,而python有GC机制,所以,del语句作用在变量上,而不是数据对象上。 del删除的 阅读全文
posted @ 2020-04-16 09:37 friedCoder 阅读(206) 评论(0) 推荐(0) 编辑
摘要:python的默认参数 python可以使用变量作为默认参数,但是该变量必须在函数定义之前就已经声明。比如 同时,对于python, 默认参数在函数定义的时候就已经计算好了 。 可以发现第1次和第3次执行func都是针对同一个list(默认list),这是因为默认参数在函数定义时就已经计算出来,且这 阅读全文
posted @ 2020-04-16 09:34 friedCoder 阅读(432) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示