当前位置:网站首页>返回文件名问题
返回文件名问题
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 结语
本文主要介绍的为返回文件名问题,解决该问题对于我们寻找文件名有极大帮助,我们可以轻松的利用此程序来找到所需要的文件名,极大地加快了我们工作的效率。
边栏推荐
- MySql - there is no insert, there is update or ignored
- Nacos database configuration
- 文件上传漏洞(二)
- The nacos source code can not find the istio package
- In-depth analysis of the initialization of member variables and local variables
- The stock price has repeatedly hit new lows, and the real estate SaaS giant is in trouble. How should Mingyuan Cloud transform and save itself?
- July 18-July 31, 2022 (Ue4 video tutorials and documentation, 20 hours. Total 1412 hours, 8588 hours left)
- punch day05
- MarkDown Formula Instruction Manual
- Vscode连接远程服务器出现‘Acquiring lock on/home/~’问题
猜你喜欢

Practice on optimizing startup performance of VS Code

How to install the specified version package with NPM and view the version number

How the Internet of Things is changing the efficiency of city operations

宝塔+FastAdmin 404 Not Found

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

Nacos数据库配置

Tips for programmers to write PPT

MySQL Advanced - MVCC (ultra-detailed finishing)

Nacos installation detailed process

A detailed introduction to the deployment and usage of the Nacos registry
随机推荐
有点奇怪!访问目的网址,主机能容器却不行
Practice on optimizing startup performance of VS Code
MySQL 5.7 installation tutorial (full-step, nanny-level tutorial)
MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
看图就懂|衡量业务增长健康的销售指标如何选择
Leetcode周赛304
About the local server problem after ue4.27 pixel streaming package
[数据集][VOC]男女数据集voc格式6188张
Nodejs installation and global configuration (super detailed)
Dataset:机器学习中常用数据集下载链接集合之详细攻略
Detailed explanation of 9 common reasons for MySQL index failure
August 2022 plan, focusing on ue4 video tutorials
专家见解|经济低迷期把握创新机会的 3 大方法
Kingdee International: Lost in half a year and last year, how does the business model of frantically burning money continue
MySQL driver jar package download -- nanny tutorial
MySQL联合查询(多表查询)
aTrust项目的相关操作与分享
蚂蚁三面:MQ 消息丢失、重复、积压问题,有哪些解决方案?
Toolbox App 1.25 新功能一览 | 版本更新
[Cartoon] 2021 full score programmer behavior comparison table (latest version)