python
strip(chart):去除头尾字符
lstrip(chart):去除头部字符
rstrip(chart):去除尾部字符
print(‘We are the {} who say “{}!”’.format(‘knights’, ‘Ni’))
1、读取txt文本出现“ ‘gbk’ codec can’t decode byte 0xbf in position 2: illegal multibyte sequence”的解决办法:open(path,“r”,encoding=‘utf-8’)->读取中文文件
2.shapes (200,2) and (3,) not aligned: 2 (dim 1) != 3 (dim 0)
上一个的输出就是下一个的输入,所以数据的维度是需要对齐(align)的,也就是上一个输出维度需要等于下一个的输入维度。很明显这里的 (200,2) 中的dim1=1维是上一个的输出维度, (3,)中的dim0=3是下一个的输入维度,两者不相等,所以报错
3.python连接mysql “Field ‘id’ doesn’t have a default value” 数据库表格选择id自动递增
4.np.loadtx(用法参考https://blog.youkuaiyun.com/weixin_43593330/article/details/89882187?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522158735619519725247633998%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=158735619519725247633998&biz_id=0&utm_source=distribute.pc_search_result.none-task-blog-2allfirst_rank_v2~rank_v25-15)
5.server_hostname cannot be an empty string or start with a leading dot.解决办法:python 3.7 修改了 ssl.py 导致了 smtplib.SMTP_SSL 的问题,如果按照原来的,改为:
import smtplib
smtplib.SMTP_SSL(host=‘smtp.gmail.com’).connect(host=‘smtp.gmail.com’, port=465)