python 基本语句
文件的读取:
with open(input_path, "r") as input_file: #读取input_path这个文件,把这个文件流叫inputfile with open(output_path, "w") as output_file:#读文件里面的每一行
2. assert
assert后面的判断语句不成立的时候抛出异常
assert a==2, 'a 不等于 2' #如果a不等于2就会抛出异常代码停在这里,不然就继续往下执行
tf:
import tensorflow_hub as hub import tensorflow as tf module_spec = hub.load_module_spec("./emlo2") elmo_module = hub.Module(module_spec) token_ph = tf.placeholder(tf.string, [None, None]) len_ph = tf.placeholder(tf.int32, [None]) lm_embeddings = elmo_module( inputs={"tokens": token_ph, "sequence_len": len_ph}, signature="tokens", as_dict=True)
3.python关于值传递还是引用传递
https://www.jb51.net/article/127667.htm
对于list,list因为是可变的,a=[1,2],b=1,python会给b一个新的地址。所以改变b不会影响a,但是temp=listnode(0),res=temp。改变res就会影响temp