Python: simple code,simple是谁


# !/usr/bin/env python3.6 
# -*- coding: utf-8 -*- 
# visual studio 2017
# 2019 10 12 Geovin Du print
from turtle import *;
import sys;
from math import ceil;
import re;
import time;
import operator;
from copy import deepcopy;
from random import randint;



print('geovindu');

# 重复元素判定
def all_unique(lst):
    return len(lst) == len(set(lst))
x = [1,1,2,2,3,2,3,4,5,6]
y = [1,2,3,4,5]
all_unique(x) # False
all_unique(y) # True

# #字符元素组成判定
from collections import Counter
def anagram(first, second):
   return Counter(first) == Counter(second)
anagram("abcd3", "3acdb") # True
#内存占用
variable = 30 
print(sys.getsizeof(variable)) # 24
#字节占用
def byte_size(string):
    return(len(string.encode('utf-8')))

byte_size('

相关内容

    暂无相关文章

评论关闭