随笔分类 -  Python3

摘要:class Solution: def sortSentence(self, s: str) -> str: words = s.split() li = ['']*len(words) for i in words: li[int(i[-1])-1]=i[0:-1] return " ".join 阅读全文
posted @ 2022-09-09 17:35 盗哥泡茶去了 阅读(34) 评论(0) 推荐(0)
摘要:class Solution: def sumBase(self, n: int, k: int) -> int: tag = True quotient = n//k #商 remainder = n%k #余数 while tag: if quotient >= k: remainder+=qu 阅读全文
posted @ 2022-09-09 16:06 盗哥泡茶去了 阅读(37) 评论(0) 推荐(0)
摘要:class Solution: def minOperations(self, logs: List[str]) -> int: result=0 for i in range(0,len(logs)): if logs[i]=='../': if result>0: result-=1 elif  阅读全文
posted @ 2022-09-09 15:24 盗哥泡茶去了 阅读(15) 评论(0) 推荐(0)
摘要:class Solution: def reorderSpaces(self, text: str) -> str: count=text.count(' ') #字符串中空格的数量 li=text.split() #默认以【空格、tab、换行、回车以及formfeed】为分隔符,将字符串分割为一个 阅读全文
posted @ 2022-09-07 18:01 盗哥泡茶去了 阅读(51) 评论(0) 推荐(0)
摘要:输出数字、字符串、表达式(操作数和运算符) >>> print(1) 1 >>> print('hello,world') hello,world >>> print(1+2) 3 输出到文件 >>> fp=open('E:/test.txt','a+') >>> print('hello,worl 阅读全文
posted @ 2022-08-09 21:06 盗哥泡茶去了 阅读(69) 评论(0) 推荐(0)
摘要:Python3 中有六个标准的数据类型: Number(数字) String(字符串) List(列表) Tuple(元组) Set(集合) Dictionary(字典) Python3 的六个标准数据类型中: 不可变数据(3 个):Number(数字)、String(字符串)、Tuple(元组); 阅读全文
posted @ 2021-08-04 16:37 盗哥泡茶去了 阅读(79) 评论(0) 推荐(0)
摘要:1.算术运算符 2.比较运算符 3.赋值运算符 4.位运算符 & 按位与运算符:参与运算的两个值,如果两个相应位都为1,则该位的结果为1,否则为0 | 按位或运算符:只要对应的二个二进位有一个为1时,结果位就为1 ^ 按位异或运算符:当两对应的二进位相异时,结果为1 ~ 按位取反运算符:对数据的每个 阅读全文
posted @ 2021-04-23 11:30 盗哥泡茶去了 阅读(79) 评论(0) 推荐(0)
摘要:一、保留字 保留字即关键字,我们不能把它们用作任何标识符名称。Python 的标准库提供了一个 keyword 模块,可以输出当前版本的所有关键字: >>> import keyword >>> keyword.kwlist ['False', 'None', 'True', 'and', 'as' 阅读全文
posted @ 2020-07-13 19:09 盗哥泡茶去了 阅读(117) 评论(0) 推荐(0)
摘要:IDE 集成开发环境(Integrated Development Enviroment) 集成了开发软件需要的所有攻击,一般包括: 图形用户界面 代码编辑器(支持 代码补全/自动缩进) 编译器/解释器 调试器(断点/单步执行) PyCharm下载 下载地址:https://www.jetbrain 阅读全文
posted @ 2020-07-07 15:50 盗哥泡茶去了 阅读(152) 评论(0) 推荐(0)
摘要:IPython IPython 中 的 “I” 代表 交互 interactive 特点 IPython 是一个 python 的 交互式 shell,比默认的 python shell 好用得多 支持自动补全 自动缩进 支持 bash shell 命令 内置了许多很有用的功能和函数 IPython 阅读全文
posted @ 2020-07-06 18:03 盗哥泡茶去了 阅读(270) 评论(0) 推荐(0)
摘要:查看系统原有Python 注:可以将python指向python3,但必须修改一些命令如yum的配置,不然会报错。 安装依赖 yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline 阅读全文
posted @ 2020-07-06 17:39 盗哥泡茶去了 阅读(141) 评论(0) 推荐(0)