IT入门 > 面试题 > python题库 >

  • 简述你对 input()函数的理解?

    日期:2019-07-29 23:12:56 点击:5251 好评:3

    在 Python3 中,input()获取用户输入,不论用户输入的是什么,获取到的都是字符串类型的。 在 Python2 中有 raw_input()和 input(), raw_input()和 Python3 中的 input()作用是一样的,input()输入的是什...

  • 面这段代码的输出结果将是什么?请解释?

    日期:2019-07-29 23:12:03 点击:1804 好评:0

    class Parent(object) x = 1 class Child1(Parent): pass class Child2(Parent): pass print Parent.x, Childx, Childx Childx = 2 print parent.x, Childx, Childx parent.x = 3 print Parent.x, Childx, Childx 结果为: 1 1 1 #继承自父类的类属...

  • print 调用 Python 中底层的什么方法?

    日期:2019-07-29 23:11:30 点击:5689 好评:0

    print 方法默认调用 sys.stdout.write 方法,即往控制台打印字符串。...

  • a=1,b=2,不用中间变量交换 a 和 b 的值?

    日期:2019-07-29 23:10:55 点击:11740 好评:0

    方法一: a = a+bb = a-ba = a-b 方法二: a = a^b b =b^a a = a^b 方法三: a,b = b,a...

  • 代码中要修改不可变数据会出现什么问题? 抛出什

    日期:2019-07-29 23:09:44 点击:12907 好评:1

    代码不会正常运行,抛出 TypeError 异常。...

  • 两个字符串是否是变位词

    日期:2019-07-27 11:25:24 点击:1534 好评:0

    class Anagram: """ @:param s1: The first string @:param s2: The second string @:return true or false """ def Solution1(s1,s2): alist = list(s2) pos1 = 0 stillOK = True while pos1...

  • 单链表逆置

    日期:2019-07-27 11:24:41 点击:2074 好评:0

    class Node(object): def __init__(self, data=None, next=None): self.data = data self.next = nextlink = Node(1, Node(2, Node(3, Node(4, Node(5, Node(6, Node(7, Node(8, Node(9)))))))))def rev(link): pre = link cur = link.next pre.next = None w...

  • 前序中序求后序

    日期:2019-07-27 11:24:17 点击:6952 好评:0

    推荐: http://blog.csdn.net/hinyunsin/article/details/6315502 def rebuild(pre, center): if not pre: return cur = Node(pre[0]) index = center.index(pre[0]) cur.left = rebuild(pre[1:index + 1], center[:index]) cur.right = rebuild(pre[index +...

  • 求两棵树是否相同

    日期:2019-07-27 11:23:39 点击:1822 好评:0

    def isSameTree(p, q): if p == None and q == None: return True elif p and q : return p.val == q.val and isSameTree(p.left,q.left) and isSameTree(p.right,q.right) else : return False...

  • 求最大树深

    日期:2019-07-27 11:23:05 点击:7067 好评:0

    def maxDepth(root): if not root: return 0 return max(maxDepth(root.left), maxDepth(root.right)) + 1...

广告位API接口通信错误,查看德得广告获取帮助