摘要:1. 创建虚拟环境 $ python -m venv test-env 2. 激活虚拟环境 windows:tutorial-env\Scripts\activate (powershell: .\test-env\Scripts\Activate.ps1) linux:source tutoria
阅读全文
摘要:shape 方法用于查看数据是几行几列的。 reshape 方法用于不更改数据的情况下,重新把数据进行规划成指定的行数和列数。 .reshape(-1, 1) -1 表示自动,1 表示整理成 1 列数据。 .reshape(2, -1) 整理成 2 行的数据。 .reshape(3, 3) 整理成
阅读全文
摘要:当通过常规命令安装 pip install pydot 和 brew install graphviz 之后,在代码中 import pydot 依旧不生效。 比如:在 tensorflow 使用 tf.keras.utils.plot_model 的时候,就会提示 Failed to import
阅读全文
摘要:倒序操作很简单,使用 reversed( ) 方法,原本是 ['a', 'b', 'c'],倒序后就是 ['c', 'b', 'a'] Ref:在线运行Python代码 Refer:Python dict技巧 Link:https://www.cnblogs.com/farwish/p/132206
阅读全文
摘要:通过 pandas 把 dict 数据封装,调用接口方法写入 csv 文件。 import pandas as pd data = [{"name": "a"}, {"name": "b"}] pd_data = pd.DataFrame.from_dict(data) pd_data.to_csv
阅读全文
摘要:import json json = '{"code": 0}' # Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance containing a JSON document) to a Python object. o
阅读全文
摘要:字节转字符串: st = str(data, encoding = "utf8") print(st) print(type(str)) # <class 'str'> 字符串转字节: by = bytes(st, encoding = "utf8") print(by) print(type(by
阅读全文
摘要:以 %%writefile request.py 开头。 下面写 python 代码,然后 shift + enter 键,可以把 python 代码写入开头指定的文件中,没有则自动创建。 以 %run request.py 的形式运行当前目录下的 python 文件。 也可以指定绝对路径。 To:
阅读全文
摘要:python 中的 list 即列表,是用中括号 [ ] 表示的数组列表; dict 即字典,是用花括号 { } 表示的 json 对象; tuple 即元祖,是用小括号表示的序列; 见到它们之间的组合并不奇怪,比如 [ ('100230343': 100), ('1003234244': 200)
阅读全文
摘要:python:https://www.python.org/downloads/ pip:https://pip.pypa.io/en/stable/installing/#upgrading-pip pip is already installed if you are using Python
阅读全文