Python: simple code

2022-10-14,,

# !/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('

《Python: simple code.doc》

下载本文的Word格式文档,以方便收藏与打印。