zoukankan      html  css  js  c++  java
  • basename/dirname 获取文件名/路径

    http://ruby-doc.org/core-2.1.2/File.html#method-c-dirname

    (1)basename(file_name [, suffix] ) → base_name 

    Returns the last component of the filename given in file_name, which can be formed using bothFile::SEPARATOR and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not nil. If suffix is given and present at the end of file_name, it is removed.

    File.basename("/home/gumby/work/ruby.rb")          #=> "ruby.rb"
    File.basename("/home/gumby/work/ruby.rb", ".rb")   #=> "ruby"


    (2)dirname(file_name) → dir_name

    Returns all components of the filename given in file_name except the last one. The filename can be formed using both File::SEPARATOR and File::ALT_SEPARATOR as the separator whenFile::ALT_SEPARATOR is not nil.

    File.dirname("/home/gumby/work/ruby.rb")   #=> "/home/gumby/work"
    
    
  • 相关阅读:
    前端-----盒子模型
    跨域
    DRF的分页
    DRF的权限和频率
    DRF 版本和认证
    DRF的视图和路由
    APIView和View的区别
    Serializers序列化组件
    RESTful
    Vuex以及axios
  • 原文地址:https://www.cnblogs.com/iwangzheng/p/3942072.html
Copyright © 2011-2022 走看看