Python学习
张亚楠·
昆明理工大学无线通信团队
展开
-
成功解决TypeError: a bytes-like object is required, not ‘str‘
出现问题:在文件写操作时出现TypeError: a bytes-like object is required, not ‘str’意思是函数write需要的参数类型是字节对象不是字符串解决办法:把str转换成bytes类型bytes(data,‘utf-8’) 或者 str.encode(data,‘utf-8’)第二个参数是编码,根据需求选择。...原创 2021-07-08 16:01:52 · 4398 阅读 · 1 评论 -
已解决——pycharm在同目录下import,pycharm会提示错误,但是可以运行
pycharm在同目录下import,pycharm会提示错误,但是可以运行原因:pycharm不会将当前文件目录自动加入自己的sourse_path。解决方案:右键make_directory as–>sources path将当前工作的文件夹加入source_root ...原创 2020-12-13 16:22:15 · 679 阅读 · 0 评论 -
【已解决】python远程连接数据库问题
第一个问题读入数据库数据出现异常,具体原因(2003, "Can't connect to MySQL server on '192.168.0.106(timeout))原因:局域网防火墙未关闭,虽然能ping通,但是无法读取数据原创 2020-12-03 19:48:09 · 1135 阅读 · 0 评论 -
解决jupyter notebook输出显示不完整问题
jupyter notebook输出——列显示不全的问题解决方法pd.set_option('display.max_columns', None) # 设置显示最大行jupyter notebook输出——行显示不全的问题解决方法pd.set_option('display.max_rows', None) # 设置显示最大行例子解决后...原创 2020-11-21 13:07:41 · 10920 阅读 · 2 评论 -
python 将一个列表切割成随机指定长度的多个列表
1.将列表list1划分为长度分别为2,2,3的三个字列表list1 = [1, 2, 3, 4, 5, 6, 7]list2 = [2,2,3]list3 = []i=0for j in list2: print(list1[i:i + j]) list3.append(list1[i:i + j]) i=i+jprint(list3) 结果2.将列表list1划分为长度分别为1,2,3的三个字列表list1 = [1, 2, 3, 4, 5,原创 2020-11-05 22:18:04 · 2023 阅读 · 0 评论 -
2020-10-24 pandas导入出现错误或者警告解决方案
错误提醒ImportError: Pandas requires version '1.3.7' or newer of 'XlsxWriter' (version '0.9.6' currently installed).出错原因版本较低,需要更新解决方法pip install --upgrade XlsxWriter发现又遇到已安装问题ERROR: Cannot uninstall 'XlsxWriter'. It is a distutils installed project an原创 2020-10-24 17:57:28 · 9151 阅读 · 0 评论 -
pip “Cannot uninstall ‘pip包‘. It is a distutils installed project...“ 解决方法
pip升级更新遇到——包已经安装更新,无法安装的错误ERROR: Cannot uninstall 'XlsxWriter'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall解决方法:忽略已安装的包pip install XlsxWriter --upgra原创 2020-10-24 17:44:33 · 1093 阅读 · 0 评论 -
python中关于sklearn 0.18的错误—— cannot import name comb
问题描述ImportError Traceback (most recent call last)<ipython-input-78-534e3eb204d1> in <module>----> 1 from sklearn.cluster import KMeans 2 # data = pd.read_csv(r'C:\Users\Administrator\Desktop\company.csv原创 2020-06-23 09:06:02 · 4919 阅读 · 2 评论 -
Python程序提示出现File "stdin",line 1错误解决方法
第一个Python程序hello.py提示出现File “”,line 1错误写第一个Python程序hello.py,内容仅有一句,print ‘hello world’,运行 Python hello.py 出错,提示:File “stdin” , line 1python hello.pySyntaxError:invalid syntax原因: 在shell脚本中,运行sh...原创 2019-10-25 10:58:30 · 148138 阅读 · 9 评论 -
了解Python编程——Python学习(三)
三、Python中的数据类型1.Python3语言中内置的基本数据类型2.C语言和Python语言的变量类型对比3.Number数值类型Python3中,只有一种整型类型int内置的type()函数可以查询变量所指的对象类型也可以使用内置的isinstance()函数来判断Python3中 True的值是1 ,False的值是0浮点只有单精度float,没有double双精度...原创 2019-09-18 20:11:19 · 430 阅读 · 0 评论 -
jupyter的常用操作——Python学习(二)
jupyter的常用操作简单代码操作File里面比较常用的就是将代码另存为其他格式,特别是.py 格式例如Pycharm。而jupyter保存的内容是 .ipynb 格式的KernelInterrupt可以打断正在执行的程序Restart可以在Interrupt执行没效果的时候使用,可以重启一下(Kernel)Restart&Clear Output可以重启同时清空原有的运...原创 2019-09-18 19:42:05 · 665 阅读 · 0 评论 -
了解Python编程——Python学习(一)
目录一.对Python程序的了解二.认识Python家族三.Python的数据类型组成四.程序中出现率最高的if-else一.对Python程序的了解Python是什么Python,与C、Java等编程一样,帮助我们更好的与计算机沟通。其功能全面,易学易用,属于可拓展的语言人生苦短,我用PythonPython背景介绍Python的作者——荷兰人Guido van Ro...原创 2019-09-17 18:49:36 · 2002 阅读 · 0 评论