python 技巧

发布时间 2023-12-05 19:15:43作者: 广爷天下无双

资方展示异常

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号

第一行设为列名

import numpy as np
array = np.array(zt1)
list = array.tolist()
list = list[0]
zt1.columns = list

sha256加密

import hashlib
def sha256_jiami(x):
'''
Parameters
----------
x : string
需要加密的字符串.

Returns
-------
字符窜加密后的字符

'''
sha256 = hashlib.sha256()
sha256.update(x.encode('utf-8'))
return sha256.hexdigest()

target_01['phone_sha256'] = target_01['Phone'].apply(sha256_jiami)