as火柴人

导航

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

java里面的传递:https://www.cnblogs.com/volcan1/p/7003440.html

posted on 2019-07-24 13:23  as火柴人  阅读(329)  评论(0编辑  收藏  举报