精华内容
参与话题
问答
  • Filenames and paths

    2019-09-29 17:19:59
    Files are organized into directories (also called ‘folders’). Every running program has a ‘current directory’, which is the default directory for most operations. For example, when you create a n....

    Files are organized into directories (also called ‘folders’). Every running program has a ‘current directory’, which is the default directory for most operations. For example, when you create a new file with open, the new file goes in the current directory. And when you open a file for reading, Python looks for it in the current directory. The module os provides functions for working with files and directories. os.getcwd returns the name of current directory. cwd stands for ‘current working directory’. A string like cwd that identifies a file is called a path. A relative path starts from the current directory; an absolute path starts from the topmost directory in the file system. The paths we have seen so far are simple filenames, so they are relative to the current directory. To find the absolute path to a file, you can use abspath, which is in the module os.path.

                           

     

    To demonstrate these functions, the following examples ‘walks’ through a directory, prints the names of all the files, and calls itself recursively on all the directories.

     

     

     

    from Thinking in Python

    转载于:https://www.cnblogs.com/ryansunyu/p/3988518.html

    展开全文
  • 本软件能在文件右键添加【复制文件名】【复制文件名并删除】【粘贴文件名】菜单。网上一直有汉化好的32位版本。然而,32位的并不能用于64位系统。本人根据官方的64位的英文版汉化,版权归原官方所有。
  • Add filenames to result". 这是什么意思呢? Kettle有一个文件名系统, 专门储存了最近生成的或者处理过的文件名列表, 以供进一步处理, 比如移动, copy或者删除 在Job的design中你能找到几个组件专门...

    在部分文件处理的kettle组件中, 你能找到一个勾选框, 名字叫 "Add filenames to result".

    这是什么意思呢?

    Kettle有一个文件名系统, 专门储存了最近生成的或者处理过的文件名列表, 以供进一步处理, 比如移动, copy或者删除

    在Job的design中你能找到几个组件专门用来处理这些被kettle记住了名字的文件.

    比如:

    Process result filenames

    Delete filenames from result

    Add filenames to result

     

    这里所有的result就是指kettle记住的那些文件名及其路径.

    比如你生成了一个文件, 然后要把它移动到另一个目录, 就可以用用这个功能.

    展开全文
  • tf.trian.match_filenames_once

    千次阅读 2018-08-27 15:06:40
    tf.trian.match_filenames_once 在构造datalist的时候经常使用,他可以利用正则表达式将需要的文件读出来作为一个list很好用,但是后面的的iterator要使用 initializable iterator ...

     tf.trian.match_filenames_once  在构造datalist的时候经常使用,他可以利用正则表达式将需要的文件读出来作为一个list很好用,但是后面的的iterator要使用 initializable iterator

    展开全文
  • 看到这个问题你应该已经下载到setuptools-28.8.0了 如果没有 那么请把下面的python拷贝下来 然后执行 你就会得到了: #!/usr/bin/env python """ Setuptools bootstrapping installer. Maintained at ...

    看到这个问题你应该已经下载到setuptools-28.8.0了

    如果没有 那么请把下面的python拷贝下来 然后执行 你就会得到了:

    
     
    #!/usr/bin/env python """ Setuptools bootstrapping installer. Maintained at https://github.com/pypa/setuptools/tree/bootstrap. Run this script to install or upgrade setuptools. """ import os import shutil import sys import tempfile import zipfile import optparse import subprocess import platform import textwrap import contextlib import json import codecs from distutils import log try: from urllib.request import urlopen from urllib.parse import urljoin except ImportError: from urllib2 import urlopen from urlparse import urljoin try: from site import USER_SITE except ImportError: USER_SITE = None LATEST = object() DEFAULT_VERSION = LATEST DEFAULT_URL = "https://pypi.io/packages/source/s/setuptools/" DEFAULT_SAVE_DIR = os.curdir def _python_cmd(*args): """ Execute a command. Return True if the command succeeded. """ args = (sys.executable,) + args return subprocess.call(args) == 0 def _install(archive_filename, install_args=()): """Install Setuptools.""" with archive_context(archive_filename): # installing log.warn('Installing Setuptools') if not _python_cmd('setup.py', 'install', *install_args): log.warn('Something went wrong during the installation.') log.warn('See the error message above.') # exitcode will be 2 return 2 def _build_egg(egg, archive_filename, to_dir): """Build Setuptools egg.""" with archive_context(archive_filename): # building an egg log.warn('Building a Setuptools egg in %s', to_dir) _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir) # returning the result log.warn(egg) if not os.path.exists(egg): raise IOError('Could not build the egg.') class ContextualZipFile(zipfile.ZipFile): """Supplement ZipFile class to support context manager for Python 2.6.""" def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() def __new__(cls, *args, **kwargs): """Construct a ZipFile or ContextualZipFile as appropriate.""" if hasattr(zipfile.ZipFile, '__exit__'): return zipfile.ZipFile(*args, **kwargs) return super(ContextualZipFile, cls).__new__(cls) @contextlib.contextmanager def archive_context(filename): """ Unzip filename to a temporary directory, set to the cwd. The unzipped target is cleaned up after. """ tmpdir = tempfile.mkdtemp() log.warn('Extracting in %s', tmpdir) old_wd = os.getcwd() try: os.chdir(tmpdir) with ContextualZipFile(filename) as archive: archive.extractall() # going in the directory subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0]) os.chdir(subdir) log.warn('Now working in %s', subdir) yield finally: os.chdir(old_wd) shutil.rmtree(tmpdir) def _do_download(version, download_base, to_dir, download_delay): """Download Setuptools.""" py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys) tp = 'setuptools-{version}-{py_desig}.egg' egg = os.path.join(to_dir, tp.format(**locals())) if not os.path.exists(egg): archive = download_setuptools(version, download_base, to_dir, download_delay) _build_egg(egg, archive, to_dir) sys.path.insert(0, egg) # Remove previously-imported pkg_resources if present (see # https://bitbucket.org/pypa/setuptools/pull-request/7/ for details). if 'pkg_resources' in sys.modules: _unload_pkg_resources() import setuptools setuptools.bootstrap_install_from = egg def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=DEFAULT_SAVE_DIR, download_delay=15): """ Ensure that a setuptools version is installed. Return None. Raise SystemExit if the requested version or later cannot be installed. """ version = _resolve_version(version) to_dir = os.path.abspath(to_dir) # prior to importing, capture the module state for # representative modules. rep_modules = 'pkg_resources', 'setuptools' imported = set(sys.modules).intersection(rep_modules) try: import pkg_resources pkg_resources.require("setuptools>=" + version) # a suitable version is already installed return except ImportError: # pkg_resources not available; setuptools is not installed; download pass except pkg_resources.DistributionNotFound: # no version of setuptools was found; allow download pass except pkg_resources.VersionConflict as VC_err: if imported: _conflict_bail(VC_err, version) # otherwise, unload pkg_resources to allow the downloaded version to # take precedence. del pkg_resources _unload_pkg_resources() return _do_download(version, download_base, to_dir, download_delay) def _conflict_bail(VC_err, version): """ Setuptools was imported prior to invocation, so it is unsafe to unload it. Bail out. """ conflict_tmpl = textwrap.dedent(""" The required version of setuptools (>={version}) is not available, and can't be installed while this script is running. Please install a more recent version first, using 'easy_install -U setuptools'. (Currently using {VC_err.args[0]!r}) """) msg = conflict_tmpl.format(**locals()) sys.stderr.write(msg) sys.exit(2) def _unload_pkg_resources(): sys.meta_path = [ importer for importer in sys.meta_path if importer.__class__.__module__ != 'pkg_resources.extern' ] del_modules = [ name for name in sys.modules if name.startswith('pkg_resources') ] for mod_name in del_modules: del sys.modules[mod_name] def _clean_check(cmd, target): """ Run the command to download target. If the command fails, clean up before re-raising the error. """ try: subprocess.check_call(cmd) except subprocess.CalledProcessError: if os.access(target, os.F_OK): os.unlink(target) raise def download_file_powershell(url, target): """ Download the file at url to target using Powershell. Powershell will validate trust. Raise an exception if the command cannot complete. """ target = os.path.abspath(target) ps_cmd = ( "[System.Net.WebRequest]::DefaultWebProxy.Credentials = " "[System.Net.CredentialCache]::DefaultCredentials; " '(new-object System.Net.WebClient).DownloadFile("%(url)s", "%(target)s")' % locals() ) cmd = [ 'powershell', '-Command', ps_cmd, ] _clean_check(cmd, target) def has_powershell(): """Determine if Powershell is available.""" if platform.system() != 'Windows': return False cmd = ['powershell', '-Command', 'echo test'] with open(os.path.devnull, 'wb') as devnull: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except Exception: return False return True download_file_powershell.viable = has_powershell def download_file_curl(url, target): cmd = ['curl', url, '--location', '--silent', '--output', target] _clean_check(cmd, target) def has_curl(): cmd = ['curl', '--version'] with open(os.path.devnull, 'wb') as devnull: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except Exception: return False return True download_file_curl.viable = has_curl def download_file_wget(url, target): cmd = ['wget', url, '--quiet', '--output-document', target] _clean_check(cmd, target) def has_wget(): cmd = ['wget', '--version'] with open(os.path.devnull, 'wb') as devnull: try: subprocess.check_call(cmd, stdout=devnull, stderr=devnull) except Exception: return False return True download_file_wget.viable = has_wget def download_file_insecure(url, target): """Use Python to download the file, without connection authentication.""" src = urlopen(url) try: # Read all the data in one block. data = src.read() finally: src.close() # Write all the data in one block to avoid creating a partial file. with open(target, "wb") as dst: dst.write(data) download_file_insecure.viable = lambda: True def get_best_downloader(): downloaders = ( download_file_powershell, download_file_curl, download_file_wget, download_file_insecure, ) viable_downloaders = (dl for dl in downloaders if dl.viable()) return next(viable_downloaders, None) def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=DEFAULT_SAVE_DIR, delay=15, downloader_factory=get_best_downloader): """ Download setuptools from a specified location and return its filename. `version` should be a valid setuptools version number that is available as an sdist for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ version = _resolve_version(version) # making sure we use the absolute path to_dir = os.path.abspath(to_dir) zip_name = "setuptools-%s.zip" % version url = download_base + zip_name saveto = os.path.join(to_dir, zip_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto) def _resolve_version(version): """ Resolve LATEST version """ if version is not LATEST: return version meta_url = urljoin(DEFAULT_URL, '/pypi/setuptools/json') resp = urlopen(meta_url) with contextlib.closing(resp): try: charset = resp.info().get_content_charset() except Exception: # Python 2 compat; assume UTF-8 charset = 'UTF-8' reader = codecs.getreader(charset) doc = json.load(reader(resp)) return str(doc['info']['version']) def _build_install_args(options): """ Build the arguments to 'python setup.py install' on the setuptools package. Returns list of command line arguments. """ return ['--user'] if options.user_install else [] def _parse_args(): """Parse the command line for options.""" parser = optparse.OptionParser() parser.add_option( '--user', dest='user_install', action='store_true', default=False, help='install in user site package') parser.add_option( '--download-base', dest='download_base', metavar="URL", default=DEFAULT_URL, help='alternative URL from where to download the setuptools package') parser.add_option( '--insecure', dest='downloader_factory', action='store_const', const=lambda: download_file_insecure, default=get_best_downloader, help='Use internal, non-validating downloader' ) parser.add_option( '--version', help="Specify which version to download", default=DEFAULT_VERSION, ) parser.add_option( '--to-dir', help="Directory to save (and re-use) package", default=DEFAULT_SAVE_DIR, ) options, args = parser.parse_args() # positional arguments are ignored return options def _download_args(options): """Return args for download_setuptools function from cmdline args.""" return dict( version=options.version, download_base=options.download_base, downloader_factory=options.downloader_factory, to_dir=options.to_dir, ) def main(): """Install or upgrade setuptools and EasyInstall.""" options = _parse_args() archive = download_setuptools(**_download_args(options)) return _install(archive, _build_install_args(options)) if __name__ == '__main__': sys.exit(main())


    No urls, filenames, or requirements specified

     

    这个问题是因为安装方法不对,需要CMD进入到setuptools-28.8.0 目录后,执行python easy_install.py virtualenv

     

    
     

     

    剩下的环境配置参考这篇文章

    http://blog.csdn.net/weihongchang/article/details/40822015

    如果

    No module named Cheetah.Template

    那么进入到setuptools里执行

     

    python easy_install Cheetahpython easy_install Cheetah

     

     

     

     

     

     

    展开全文
  • <!--google_ad_client = "pub-8333940862668978";/* 728x90, 创建于 08-11-30 */google_ad_slot = "4485230109";google_ad_width = 728;google_ad_height = 90;//--><script type="text/javascript"
  • OpenFileDialogFileNameFileNames

    千次阅读 2015-06-24 17:00:49
    打开对话框的这两个方法均返回选定文件的全路径,包括目录及文件名。 不同的是: 第一个可以单选和多选(通过设置ofd.Multiselect = true;),返回值为string;若单选则返回此文件名,若多选则返回选定的第一个...
  • System.IO.Path.GetFullPath(openFileDialog1.FileName); //绝对路径 System.IO.Path.GetExtension(openFileDialog1.FileName); //文件扩展名 System.IO.Path.GetFil...
  • 关于OpenFileDialog的使用 1、 OpenFileDialog控件有以下基本属性 InitialDirectory 对话框的初始目录 Filter 要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|所有...
  • 1:C# OpenFileDialog.ShowDialog 打不开,程序无响应 环境:win7 .Net framework2.0 现象; c#写的一个程序,在xp下点击文件打开按钮没有任何问题,但在我的win7下,点击则不弹出打开文件对话框,程序忙且无响应 ...
  • 前几天帮人做了个小软件,发给用户后,过了天便收到软件运行出错消息....System.Windows.Forms.OpenFileDialog.get_SafeFileName()"。。 具体信息 打开源代码...找到到了OpenFileDialog.SafeFileName这句 由fil
  • OpenFileDialog打开文件对话框(详解)

    万次阅读 2019-05-09 03:17:49
    C# OpenFileDialog打开文件对话框(详解) 一、打开文件对话框(OpenFileDialog) 1、 OpenFileDialog控件的基本属性 InitialDirectory:对话框的初始目录 Filter: 获取或设置当前文件名筛选器字符串,例如,“文本...
  • OpenFileDialog获取文件名和文件路径问题 原文:OpenFileDialog获取文件名和文件路径问题 ...System.IO.Path.GetFullPath(openFileDialog1.FileName); //绝对路径 System.IO.Path.G...
  • 这个功能我的使用场景是这个样子的:tool运行的时候保存了几种log,查看不同的问题需要打开不同的log,为不同log放在了不同的文件夹下面。
  • dim filename as string = openfiledialog.filenamedim fileinfo as new FileInfo(filename)dim filepath as string = fileinfo.DirectoryNamedim name as string = fileinfo.name
  • OpenFileDialog使用

    千次阅读 2018-07-11 14:53:13
    文件对话框(FileDialog)一、打开文件对话框(OpenFileDialog) 1、 OpenFileDialog控件有以下基本属性InitialDirectory 对话框的初始目录Filter 要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|...
  • 用到了tf.train.match_filenames_once这个函数去读取tfrecords文件,却不知道文件是否已经读取到,
  • #使用tf.train.match_filenames_once函数获取文件列表 files=tf.train.match_filenames_once("data.tfrecords-*") #通过tf.train.string_input_producer函数创建输入队列,输入队列中的文件列表为 #tf.train.mac
  • import as # 获取符合正则表达式的文件列表r"C:\Users\Desktop\工作计划*"with as print(sess.run(file_names)) 结果 [b'C:\\Users\\qyk\\Desktop\\\xe5\xb7\xa5\xe4\xbd\x9c\xe8\xae\xa1\xe5\x88\x92\\...
  • 1、安装相关软件包:tftpd(服务端),tftp(客户端),xinetd, openbsd-inetdsudo apt-get install tftpd tftp xinetd openbsd-inetd 有时需要单个单个的下载安装每个软件,另外xinetd与openbsd-inetd两个中只能装...
  • 文章目录前言一、完整代码二、实现效果 ...savedfilename = dest + filenames[i].substr(55); 报错: [[noreturn]] static void _Xlen() 经过百度,发现代码中的55意味着path的字符串长度。修改代码为 int len .
  • Can't find a suitable configuration file in this directory or any parent. Are you in the right directory? Supported filenames: docker-compose.yml, docker-compose.yaml
  • 用winrar打开crx,然后解压缩,把_metadata的文件夹改名称为metadata,加载即可
  • qa反映每次发布后都要重新强制刷新浏览器缓存,非常不友好,去网上查了一下,发现可以在nuxt.config.js中通过设置filenames在打包过程中通过哈希值进行版本控制 API: 构建配置 - NuxtJS - filenames 开始时的配置...
  • 简    注册 登录   添加关注 作者 婉卿容若 2016.04.29 ...iOS:编译时出现"no such file or directory:xxx"以及"use twice...filenames are used to distinguish pr
  • 此处用RichTextBox控件举例>>> 在窗体对应的类中处理Load事件可以为openfiledialog设置Filter的属性: private void Form1_Load(object sender, EventArgs e) ... openFileDialog1.FileName = ""; openFileDialo
  • 执行tensorflow程序时报错...tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value matching_filenames [[Node: matching_filenames/read = Identity[T=DT_S...
  • this.openFileDialog1.InitialDirectory = "d:\\";//注意盘符的书写规范 this.openFileDialog1.ShowDialog(); Filter要在对话框中显示的文件筛选器,例如,"文本文件(*.txt)|*.txt|所有文件(*...
  • 报错:AttributeError: module 'tensorflow.contrib.data' has no attribute 'TFRecordDataset' 在TensorFlow 1.3中,Dataset API是放在contrib包中的: tf.contrib.data.Dataset 而在TensorFlow 1.4中,Dataset...

空空如也

1 2 3 4 5 ... 20
收藏数 53,068
精华内容 21,227
关键字:

filenames