python - python检查字符串是否不包含“。”
问题描述
if '.' not in filename:
if not os.path.exists("shortcut"):
os.mkdir("shortcut")
shutil.copy(filename,"shortcut") **this row is line 70**
os.remove(filename)
print("shortcut don")
这是我的代码我在运行我的代码时在下面的图片中遇到这个错误
解决方案
如果你有一个字符串,你可以只做关键字:
strval = './test'
if '.' not in strval:
print('this won\'t happen')
else:
print('there was a period in the string')
如果您使用的是其他类型/功能,那么它应该有类似的东西
推荐阅读
- regex - 在 Angular 中验证电话号码
- python - VSCode:如何将模块从我的代码路径导入到同一路径中的另一个文件?
- webrtc - 当主机和 srflx 候选者不工作且仅中继工作时,WebRTC iceTransportPolicy 'all' 不会形成连接
- python - 如何计算两个日期之间的事件总和
- c# - 如何在文本框中只允许数字数据
- javascript - 如何在 JS 中进行搜索
- reactjs - gatsby-image 映射多个查询
- coffeescript - ReferenceError: handle is not defined at vm.js:1:1 (我完全不知道)
- python - 如何通过检查是否已在 selenium python 中单击来取消选中复选框
- python - 如何在odoo13中设置模块图标?