
python
python学习记录
喵呜嘻嘻嘻
这个作者很懒,什么都没留下…
展开
-
Win7批量执行Python文件
平时都是用Pycharm跑代码,但是每次都需要在Configuration里修改Parameters,跑完一个才能重新修改跑下一个,很不方便,于是决定借助.bat文件实现批量执行。原创 2023-06-10 21:25:55 · 743 阅读 · 0 评论 -
Pycharm:踩坑记录/窍门分享
当使用PyCharm的Debug模式时,最好用的莫过于Debug Console,它与断点相配合可以实现类似于Jupyter Notebook的逐块运行代码的效果。但是今天我突然发现Debug Console无法交互了,也即“>>>”没有出现,且“Show Debug Console”的按钮也不见了,非常着急。最后找到了原因,在Run/Debug Configurations的Execution中,要取消勾选第一项“Emulate terminal in output console”。原创 2022-12-04 11:17:43 · 879 阅读 · 0 评论 -
Python:except和except Exception as e:的区别
except和except Exception as e的区别原创 2022-10-12 18:25:29 · 3403 阅读 · 0 评论 -
Python:defaultdict
当字典中的值是列表,且想向列表中不断添加元素,可使用defaultdict:Python数据结构和算法6:字典中的键如何映射多个值原创 2022-09-16 22:06:02 · 225 阅读 · 0 评论 -
Python类:__dict__/@classmethod
自学中原创 2022-07-26 00:04:01 · 316 阅读 · 0 评论 -
使用Visual Studio Code跑python代码的二三事
跑.py文件需要先选择一个解释器。(我们之所以可能需要多个环境是因为,对于不同的任务我们可能需要一个包的不同版本,但是一个环境不能安装一个包的多个版本,所以就需要多个环境;至于环境和解释器的关系,暂时没搞清楚…)......原创 2021-04-29 22:22:14 · 97 阅读 · 0 评论 -
Python:Jupyter Notebook使用中的问题
在使用Jupyter Notebook时遇到:IOPub data rate exceeded.The notebook server will temporarily stop sending outputto the client in order to avoid crashing it.解决方法:打开Anaconda Prompt输入jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10...原创 2022-03-04 21:58:31 · 1025 阅读 · 0 评论 -
Python:安装包
python安装包时可能出现的问题原创 2022-01-10 16:46:23 · 779 阅读 · 0 评论 -
Python模块:argparse/json
argparse模块用法实例详解 本文主要参考:知乎用户原创 2021-09-24 15:46:51 · 231 阅读 · 0 评论 -
Python:对多个DataFrame的遍历
错误写法:df_set = [stats_V25A, stats_5B, stats_7B]for df in df_set: df.index = range(2014, 2021) df = df.fillna(0) df.loc[df.shape[0]] = [df[column].mean() for column in list(df.columns)] df.rename(index={df.shape[0]-1: 'mean'}, inplace=True)原创 2021-05-20 15:00:42 · 1832 阅读 · 0 评论 -
Python:if __name__ == ‘__main__‘ 如何正确理解?
本文主要参考:知乎用户在此对作者表示感谢!// file one.pydef func(): print("func() in one.py")print("top-level in one.py")if __name__ == "__main__": print("one.py is being run directly")else: print("one.py is being imported into another module")// file tw原创 2021-05-17 18:52:13 · 100 阅读 · 0 评论 -
Python:random.seed()
random.seed() 会改变随机生成器的种子;传入的数值用于指定随机数生成时所用算法开始时所选定的整数值,如果使用相同的seed()值,则每次生成的随机数都相同;如果不设置这个值,则系统会根据时间来自己选择这个值,此时每次生成的随机数会因时间的差异而有所不同。...原创 2021-04-29 22:32:56 · 133 阅读 · 0 评论 -
Python:*与**
本文主要参考:Python中的*使用_yhs的博客-优快云博客在此对作者表示感谢!调用函数时使用*和**对于函数test,test(*args):若args 等于1, 2, 3,则这个代码就等价于 test(1, 2, 3) 。test(**kwargs):若kwargs 等于 {‘a’:1, ‘b’:2, ‘c’:3} ,则这个代码就等价于 test(a=1, b=2, c=3) 。定义函数时使用*和**def test(*args): 若调用test(1, 2, 3)的话,则args的原创 2021-02-13 22:57:11 · 107 阅读 · 0 评论 -
Python:logging日志模块
本文主要参考:Python实用教程系列——Logging日志模块 - 那个百分十先生的文章 - 知乎在此对作者表示感谢!在Python中,logging可以代替print()函数在代码调试中进行日志打印等。后者只适用于较小的程序中。但是在实际的工程项目中,我们需要保存程序运行的日志,以排查程序在某一个时候崩溃的具体原因,以便及时定位bug进行抢救。一、日志等级logging中的日志等级如下:设置打印日志的级别,level级别以上的日志会打印出。默认WARNING 级别。level = log原创 2020-12-30 15:11:43 · 283 阅读 · 1 评论