본문 바로가기

app/python

(50)
python dict in list sort to dict value from operator import itemgetter temp_list = []temp_dict = dict()temp_dict["status"] = 1temp_list.append(temp_dict)temp_dict = dict()temp_dict["status"] = 10temp_list.append(temp_dict) sorted(temp_list, key=itemgetter('status'), reverse=True)
python 오늘의 요일 구하기 python get today of the week from datetime import datetoday = date.today()weekday = today.strftime("%A").lower()
python regex special symbol identification example if you want to string inner one or more special symbol charter str = "qwe123!@#" import rep = re.compile('[^a-zA-Z0-9]+')print bool(p.search(str))-> True if you want to string inner only special symbol charter import rep = re.compile('[a-zA-Z0-9]+')if bool(p.search(str)) == False:print "use only special symbol charter"
python warning pep8 closing bracket does not match visual indentation python warning pep8 closing bracket does not match visual indentation This is because the warning is incorrect convention grammar. Incorrect code Correct code End!!
no module named setuptools curl https://bootstrap.pypa.io/ez_setup.py -o - | python to installed $ sudo python setup.py install to worked!!
python Fibonacci Sequence x = 0y = 1p = 0for i in range(10): print p p = x + y x = y y = p
python aes encrypt decrypt def AESencrypt(password, plaintext, base64=False): import hashlib, os from Crypto.Cipher import AES SALT_LENGTH = 32 DERIVATION_ROUNDS=1337 BLOCK_SIZE = 16 KEY_SIZE = 32 MODE = AES.MODE_CBC salt = os.urandom(SALT_LENGTH) iv = os.urandom(BLOCK_SIZE) paddingLength = 16 - (len(plaintext) % 16) paddedPlaintext = plaintext+chr(paddingLength)*paddingLength derivedKey = password for i in range(0,DERIVA..
utf8 string to int utf8_str = u'1'ascii_int = int(utf8.encode("ascii", "ignore"))