当前位置:网站首页>返回文件名问题
返回文件名问题
2022-08-02 06:02:00 【算法与编程之美】
1 问题
请写一个函数,该函数可以返回字符串“Score.excel”的文件名。
2 方法
首先,我们先定义一个函数,给定一个n作为“计数器”再利用循环遍历,直到遍历到“.”;再利用切片,我们就可以得到所需的文件名。
3 实验结果与讨论
通过实验、实践等证明提出的方法是有效的,是能够解决开头提出的问题。
代码清单 1
| def my_0(x): n = 0 for i in str(x): n = n+1 if i == '.': break return str(x)[:n-1] d = 'Score.excel' print(my_0(d)) |
4 结语
本文主要介绍的为返回文件名问题,解决该问题对于我们寻找文件名有极大帮助,我们可以轻松的利用此程序来找到所需要的文件名,极大地加快了我们工作的效率。
边栏推荐
- chrome plugin development guide
- love
- MySQL高级SQL语句(二)
- 8/1 思维+扩展欧几里得+树上dp
- Launch Space on-premises deployment (local) Beta!
- C# Coding Conventions Handbook
- MySQL database video tutorial from beginner to proficient
- Analysis of the source code of the JS UI framework of Hongmeng system
- APT + Transform 实现多模块应用Application生命周期分发
- MySQL driver jar package download -- nanny tutorial
猜你喜欢

专家见解|经济低迷期把握创新机会的 3 大方法

Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains

MySQL经典50道练习题及全网最详细解析

Nacos database configuration

Xgboost报错ValueError:无效的形状:标签(1650 2)

typescript ‘props‘ is declared but its value is never read 解决办法

node安装及环境配置

nacos源码启动找不到istio包

MySQL 23 classic interviews hang the interviewer

MySQL 23道经典面试吊打面试官
随机推荐
Nacos安装详细过程
.NET Static Code Weaving - Rougamo Release 1.1.0
ue先视频教程后深入
How the Internet of Things is changing the efficiency of city operations
振兴农村循环经济 和数链串起农业“生态链”
July 18-July 31, 2022 (Ue4 video tutorials and documentation, 20 hours. Total 1412 hours, 8588 hours left)
Nacos客户端启动出现9848端口错误分析(非版本升级问题)
Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
npm does not recognize the "npm" item as the name of a cmdlet, function, script file, or runnable program.Please check the spelling of the name, and if the path is included, make sure the path is corr
MySQL 23道经典面试吊打面试官
request.getSession(),的故事
How to install the specified version package with NPM and view the version number
zabbix email alarm and WeChat alarm
Nacos database configuration
Servlet
Reverse resolve dns server
MySQL classic 50 practice questions and the most detailed analysis of the whole network
About the local server problem after ue4.27 pixel streaming package
c语言指针运算
Servlet