
python
whblv
小白
展开
-
Python 练习题总结
1.Given an array of one's and zero's convert the equivalent binary value to an integer. Eg: [0, 0, 0, 1] is treated as 0001 which is the binary representation of 1 常规解法:def binary_array_to_number(a...原创 2018-05-22 14:51:16 · 574 阅读 · 0 评论 -
Python实现字符串反转的几种方法
原文链接:https://www.cnblogs.com/taceywong/p/8045127.html面试遇到的一个特无聊的问题~~~要求:在Python环境下用尽可能多的方法反转字符串,例如将s = "abcdef"反转成 "fedcba"第一种:使用字符串切片result = s[::-1]第二种:使用列表的reverse方法l = list(s) result = "".join(l.r...转载 2018-05-24 19:19:15 · 372 阅读 · 0 评论