当前位置:网站首页>返回文件名问题
返回文件名问题
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 结语
本文主要介绍的为返回文件名问题,解决该问题对于我们寻找文件名有极大帮助,我们可以轻松的利用此程序来找到所需要的文件名,极大地加快了我们工作的效率。
边栏推荐
- nacos源码启动找不到istio包
- 8/1 思维+扩展欧几里得+树上dp
- 武汉高性能计算大会2022举办,高性能计算生态发展再添新动力
- 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
- How does abaqus quickly import the assembly of other cae files?
- MySQL 23 classic interviews hang the interviewer
- MarkDown Formula Instruction Manual
- Servlet
- MySQL high-level statements (1)
- Detailed explanation of 9 common reasons for MySQL index failure
猜你喜欢

optional

mysql索引失效的常见9种原因详解

蚂蚁三面:MQ 消息丢失、重复、积压问题,有哪些解决方案?

CAT1 4G+Ethernet development board Tencent cloud mobile phone WeChat applet display temperature and delivery control

Nacos installation configuration and single-machine deployment tutorial

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

有点奇怪!访问目的网址,主机能容器却不行

MySQL 23道经典面试吊打面试官

MySQL 5.7 installation tutorial (full-step, nanny-level tutorial)

HCIP BGP Comprehensive Experiment Establishing peers, route reflectors, federation, route announcement and aggregation
随机推荐
MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
optional
MySQL Advanced Study Notes
.NET静态代码织入——肉夹馍(Rougamo) 发布1.1.0
MySQL 5.7 installation tutorial (full-step, nanny-level tutorial)
Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
项目开发规范
暑期总结(三)
使用jOOQ 3.14合成外键在视图上写隐式连接
MySQL索引常见面试题(2022版)
PHP Warning: putenv() has been disabled for security reasons in phar
c语言指针运算
Nacos database configuration
[Cartoon] 2021 full score programmer behavior comparison table (latest version)
Node installation and configuration of environment variables
(Notes are not completed) [Graph Theory] Traversal of graphs
Reverse resolve dns server
HCIP 第二天
node安装及环境变量配置
nacos源码启动找不到istio包