上一页 1 ··· 43 44 45 46 47
摘要: python字符串与列表的相互转换 学习内容: 1.字符串转列表 2.列表转字符串 1. 字符串转列表 str1 = "hi hello world" print(str1.split(" "))输出:['hi', 'hello', 'world'] 2. 列表转字符串 l = ["hi","hel 阅读全文
posted @ 2019-03-10 14:17 oldby 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 笔记: python if not 判断是否为None的情况 if not x if x is None if not x is None if x is not None`是最好的写法,清晰,不会出现错误,以后坚持使用这种写法。 使用if not x这种写法的前提是:必须清楚x等于None, Fa 阅读全文
posted @ 2019-03-10 13:03 oldby 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 错误记录 class Solution: def romanToInt(self, s: str) -> int: d = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000} r=0 for i in range(len(s)): if d[s[ 阅读全文
posted @ 2019-03-09 18:06 oldby 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题目描述 方法一:转换为字符串 class Solution: def isPalindrome(self, x: int) -> bool: if x<0: return False else: y=str(x)[::-1] return y==str(x) 方法二;数字反转 class Solu 阅读全文
posted @ 2019-03-09 17:19 oldby 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Python join()方法 join()方法语法: str.join(sequence) 参数 sequence -- 要连接的元素序列。 返回值 返回通过指定字符连接序列中元素后生成的新字符串。 实例 #!/usr/bin/python # -*- coding: UTF-8 -*- str 阅读全文
posted @ 2019-03-09 16:42 oldby 阅读(225) 评论(0) 推荐(0) 编辑
上一页 1 ··· 43 44 45 46 47