Python
安生Anna
爱学习进步慢的笨少女
展开
-
Python语法速查表
由于学的语言很杂乱又不精深,混乱的脑袋常常搞不清楚,所以做一个速查表类似的东西,持续更新中…Printing# Helloprint('Hello')# Hello worldprint('Hello' + ' ' + 'world')# Hello worldprint('Hello', 'world')# Hello worldprint('Hello' + ' ' + 'world')# Hello worldprint('Hello' + '\t' + 'worl原创 2021-06-02 18:09:08 · 346 阅读 · 0 评论 -
open()使用简介 - python
open()使用简介 - python快速使用open() 用于新建文件:file = open(‘path’+filename+‘文件格式’,‘w’)例子import osname=input('请输入:')file = open('C:\\Users\\shen\\Desktop\\pythonworkfile\\' + name + '.txt', 'w')if os.path.exists('C:\\Users\\shen\\Desktop\\pythonworkfile\\'):原创 2020-11-30 17:41:00 · 351 阅读 · 0 评论 -
find the most frequent pair in the list of dictionary - python
这个是COMP1531的一次作业:A pickled file with data in it is stored in shapecolour.p. Write a function most_common inside program unpickle.py that un-pickles this file, and analyses the data to returns what the most common shape-colour pair is.The return value of原创 2020-11-30 17:19:53 · 368 阅读 · 0 评论 -
*args的切片问题
*args的类型为tuple,一般是不能随意更改的,除非有新的tuple取代# Incorrect*args = ['Hi', 'Bye']function(args[1:], **kargs) = function(['Bye'], **kargs)# Correct*args = ['Hi', 'Bye']*args = args[1:]function(*args, **kargs) = function('Bye', **kargs)关键的问题在于*args取tuple中的数来用,原创 2020-11-20 17:47:23 · 228 阅读 · 0 评论 -
Python基础操作- Updating...
字符串判断str.isdigit()# method1'animals'.isdigit()# method2str.isdigit('animals')输出为True or False注意1.使用的是str,而不是string2.由于负数的符号-为string,应该去掉符号再操作int('-12345') => int("12345")...原创 2020-11-20 16:37:01 · 180 阅读 · 1 评论