随笔分类 -  Python 基础篇

学习一下 Python 基础知识!努力加油!
摘要:C: strlen() int main() { const char* str = "I love coding."; printf("%d", strlen(str)); return 0; } C++: str.length() str.size() int main() { string s 阅读全文
posted @ 2020-03-19 19:18 SheepCore 阅读(277) 评论(0) 推荐(0)
摘要:1.Description: 2.Example: Input: 3 1 2 3 2 3 4 9223372036854775807 -9223372036854775808 0 Output: Case #1: false Case #2: true Case #3: false 3.soluti 阅读全文
posted @ 2020-03-01 20:01 SheepCore 阅读(263) 评论(0) 推荐(0)
摘要:1.Description: Now you are asked to solve a more general problem: find the first K-digit prime in consecutive digits of any given L-digit number. 2.Ex 阅读全文
posted @ 2020-03-01 19:51 SheepCore 阅读(235) 评论(0) 推荐(0)
摘要:1.Description: The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which 阅读全文
posted @ 2020-03-01 19:41 SheepCore 阅读(231) 评论(0) 推荐(0)
摘要:1. substr() 方法使用 string substr (size_t pos = 0, size_t len = npos) const;pos: 截取初始位置(从头开始截取pos=0)len: 截取字符长度 1 // using substr 2 string fullName = "Sh 阅读全文
posted @ 2020-02-28 14:21 SheepCore 阅读(3340) 评论(0) 推荐(0)
摘要:1. 简单列表解析 假设我们需要创建一个列表为:[0,0,0,0,0,0, 0,0,0, 0](size=10) 显然这样写0很费劲。所以有一种叫做列表解析的东西可以快速生成: >>> [0 for i in range(10)] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # 还 阅读全文
posted @ 2020-02-26 23:23 SheepCore 阅读(1723) 评论(0) 推荐(0)
摘要:1. rstrip()方法,去掉字符串结尾空格 >>> name = "Sheep Core " >>> name.rstrip() 'Sheep Core' #已经去掉末尾空格 note: r 表示 right! 补充: 2. lstrip() 方法,去掉字符串开头空格 >>> name = " 阅读全文
posted @ 2020-02-26 22:32 SheepCore 阅读(13265) 评论(0) 推荐(1)