标题可能与我的问题无关,因为我实际上并不需要无线文件传输脚本,我需要一个文件管理器类型。在
我想要的东西,我可以连接我的手机与我的电脑(例如:热点和wifi),然后我想显示文本文件浏览器(我有它的代码),通过发送所有文件和文件夹列表使用os.listdir()
,每当选择的选项是一个文件(os.path.isdir() == False
),我想传输文件并运行它(如:图片,视频等)。在
我编写的文件浏览器代码运行在windows和Android上(在做了一些更改之后),使用qpython
。在
我的密码
import os
def FileBrowser(cwd = os.getcwd()):
while True:
if cwd[-1:] != "\\":
cwd = cwd + "\\"
files = os.listdir(cwd)
count = 1
tmpp = ""
print("\n\n" + "_"*50 +"\n\n")
print(cwd + "\n")
for f in files:
if os.path.isdir(cwd + f) == True:
s1 = str(count) + ". " + f
tmps1 = 40 - (len(s1)+5)
t2 = int(tmps1/3)
s1 = s1 + " " * t2 + "-" * (tmps1 - t2)
print(s1 + "<dir>")
else:
print(str(count) + ". " + f + tmpp)
count = count + 1
s = raw_input("Enter the file/Directory: ")
if s == "...":
tmp1 = cwd.count("\\")
tmp2 = cwd.rfind("\\")
if tmp1 > 1:
cwd = cwd[0:tmp2]
tmp2 = cwd.rfind("\\")
cwd = cwd[0:tmp2+1]
continue
else:
continue
else:
s = int(s) - 1
if os.path.isdir(cwd + files[s]) == True:
cwd = cwd + files[s] + "\\"
continue
else:
f1 = files[s]
break
return f1
def main():
fb = FileBrowser()
main()
您可能需要socket programming。在你的电脑和你的智能手机之间建立一个链接(连接),然后尝试传输文件
使用Python的一种非常天真的方法是转到要服务的目录的根目录并使用:
在8000端口连接到它。在
相关问题 更多 >
编程相关推荐