连续循环(noob) [英] Make a continuous loop (noob)

查看:98
本文介绍了连续循环(noob)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我现在学习编程非常新手我试着通过我过去几天学到的一些东西来测试自己但是我现在卡在它上面。



我试图做一个小东西,搜索一个目录(F :)是我的usb并告诉我它是否是找到了与否。我希望它能够在没有usb的情况下运行并继续寻找当我插入它时找到它。我只是坚持创建循环任何帮助将不胜感激。



感谢



什么我试过了:



我试过使用while循环到目前为止还不是100%肯定。

这就是我的意思坚持



导入os

导入系统

导入shutil





def搜索(路径名):

返回os.path.exists(路径名)



如果搜索(F:\\):

打印找到!

elif搜索(F:\\)= =错误:

打印f not found



到目前为止这是我最终希望能找到的文件并在找到它后将其复制到F:\\。

hello,

I am extremely new to learning to program at the moment im trying to test my self with a few things ive learnt over the past few days but i am stuck at the moment on it.

Im trying to make a little thing that will search for a directory ( F: ) being my usb and tell me if it has found it or not. i want it to be able to run without the usb in and keep looking then when i plug it in find it. im just stuck on creating the loop any help will be appreciated.

thanks

What I have tried:

ive tried using while loops so far just not 100 % sure.
this is what i am stuck on

import os
import sys
import shutil


def search(pathname):
return os.path.exists(pathname)

if search("F:\\"):
print " found!"
elif search("F:\\") == False :
print " f not found"

so far this is what i have eventually i want to be able to find a file and copy it to F:\\ once it has found it.

推荐答案

我建​​议你去 Python教程 - Python 3.4.7文档 [ ^ ]并仔细研究。您将学到的不仅仅是在此处发布基本问题。
I suggest you go to The Python Tutorial — Python 3.4.7 documentation[^] and work through it carefully. You will learn far more than posting basic questions here.


这篇关于连续循环(noob)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆