月度归档: 2019年7月

5 篇文章

thumbnail
Python的输入输出
一:Python2.x版本下的输入输出 Python2.x 下的输入 1)raw_input 格式:result = raw_input("提示信息") 功能:1)会等待用户输入内容,直到用户按下Enter 2)会将用户输入的内容当做"字符串",传递给接收的变量 2)input 格式:result = input("提示信息") 功能: 1):会等…
thumbnail
binary_search[二分法检索][折半查找]
""" This is pure python implementation of binary search algorithm For doctests run following command: python -m doctest -v binary_search.py or python3 -m doctest -v binary_sea…
thumbnail
quine_mc_cluskey[python][数据结构]
def compare_string(string1, string2): l1 = list(string1) l2 = list(string2) count = 0 for i in range(len(l1)): if l1[i] != l2[i]: count += 1 l1[i] = '_' if count > 1: retur…
thumbnail
basic_binary_tree[基本二叉树][python]
class Node: # 这是一个带有构造函数的类节点,其中包含类型数据的数据变量和左右指针。 def __init__(self, data): self.data = data self.left = None self.right = None def display(tree): #按顺序遍历树 if tree is None: retu…