我有以下代码尝试删除 Windows 7 计算机上的文件:
// check if this item has an uploaded image file
var imageFullPathName = __dirname + "/../public/images/" + req.params.itemId;
logger.log("imageFullPathName = " + imageFullPathName);
var normalizedPathName = path.normalize(imageFullPathName);
logger.log("normalizedPathName = " + normalizedPathName);
// delete the image if it exists
fs.exists(normalizedPathName, function(exists) {
console.log("Found the file: " + normalizedPathName);
normalizedPathName = normalizedPathName.replace(/\\/g,"\\\\");
console.log("New path name = " + normalizedPathName);
fs.unlink(normalizedPathName, function(err){
if (err){
console.error("Error in call to fs.unlink");
}
});
});
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
imageFullPathName = C:\IronKey\hes\cscie-71\project\medical-interchange\routes/../public/images/5658e5612103cb2c41000006
规范化路径名称 = …
我正在尝试在一个简单的程序中打印python张量。该程序使用张量流读取器从文件中读取虹膜数据集。如果我取消注释该程序的最后一行,它将永远挂起。目标是打印sepal_length,sepal_width等。我该怎么做才能打印sepal_length张量?
import tensorflow as tf
def read_csv(batch_size, file_name, record_defaults):
filename_queue = tf.train.string_input_producer(["iris.data"])
reader = tf.TextLineReader(skip_header_lines=1)
key, value = reader.read(filename_queue)
# decode_csv will convert a Tensor from type string (the text line) in
# a tuple of tensor columns with the specified defaults, which also
# sets the data type for each column
decoded = tf.decode_csv(value, record_defaults=record_defaults)
# batch actually reads the file and loads "batch_size" rows in a single tensor
return tf.train.shuffle_batch(decoded,
batch_size=batch_size,
capacity=batch_size * 50,
min_after_dequeue=batch_size)
with tf.Session() as …Run Code Online (Sandbox Code Playgroud) 我是tensorflow的新手,我试图编写一个tensorflow程序来递归计算斐波那契数。下面的程序是我最终得到的,但是由于许多我不理解的错误而失败了。有人可以帮助我了解我在做什么以及如何解决。这是我的程序:
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
with tf.Graph().as_default() as g:
fib_seed_0 = tf.Variable(0, name = "fib_seed_0")
fib_seed_1 = tf.Variable(1, name = "fib_seed_1")
def fib(n):
return tf.cond(tf.equal(n, fib_seed_0), lambda: tf.identity(n),
lambda: tf.cond(tf.equal(n, fib_seed_1), lambda: tf.identity(n),
lambda: tf.add(fib(tf.subtract(n, 1)), fib(tf.subtract(n, 2)))))
fib_to_calc = tf.Variable(5, name = "fib_to_calc")
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
print(sess.run(fib(fib_to_calc)))
Run Code Online (Sandbox Code Playgroud)
这是上面的tensorflow程序试图在python翻译中执行的操作:
def F(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return F(n-1) + F(n-2)
Run Code Online (Sandbox Code Playgroud)
这是错误日志的示例。它不断地:
Traceback (most recent call last): …Run Code Online (Sandbox Code Playgroud) 我对 elisp 编程真的很陌生,我正在尝试编写一个 Emacs elisp 函数来删除突出显示区域中的所有非 ASCII 字符。我在这里找到了一个关于如何查找非 ASCII 字符的示例 elisp 函数:https : //www.emacswiki.org/emacs/FindingNonAsciiCharacters。我试图自己修改它,但无法让它工作。有人可以告诉我如何修改以下 elisp 函数以删除 GNU Emacs 中突出显示区域中的所有非 ASCII 字符:
(defun find-first-non-ascii-char ()
"Find the first non-ascii character from point onwards."
(interactive)
(let (point)
(save-excursion
(setq point
(catch 'non-ascii
(while (not (eobp))
(or (eq (char-charset (following-char))
'ascii)
(throw 'non-ascii (point)))
(forward-char 1)))))
(if point
(goto-char point)
(message "No non-ascii characters."))))
Run Code Online (Sandbox Code Playgroud) python ×2
tensorflow ×2
character ×1
emacs ×1
javascript ×1
node.js ×1
recursion ×1
unicode ×1