摘要: 英文题目:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed 阅读全文
posted @ 2018-08-23 17:02 slarker 阅读(722) 评论(0) 推荐(0) 编辑
摘要: 最近刷leetcode遇到分行取字符串再重新拼接的题目,解题过程中使用了动态生成变量的相关办法。后来发现用字典更加简单。 动态生成如下: 其中运用了locals()来返回变量。 这个方法其实很一般,如果运用迭代来生成字典则非常简单。 附动态生成变量与字典的截图代码对比: 字典显得简洁的多,更适合py 阅读全文
posted @ 2018-08-23 16:48 slarker 阅读(5412) 评论(0) 推荐(0) 编辑