file_os

# _*_ coding:utf-8 _*_
# @Time :2020/1/8 23:33
# @Author :dery
# @File :file_operate.py
# @Software :PyCharm
'''
: c:\p1\girl.jpg
:c:\p2\girl.jpg

'''
import os
#
# with open(r'D:\pythoncode\p1\girl.jpg', 'rb') as stream:
# container = stream.read()
# print(stream.name)
# file = stream.name
# filename = file[file.rfind('\\')+1:]
# print(filename)
# with open(r'D:\pythoncode\p2\girl.jpg', 'wb') as wstream:
# wstream.write(container)
# print(' ')

#
# path = os.path.dirname(__file__) # ( )
# print(path)
# result = os.path.join(path, 'a1.jpg') #
# r = os.path.isabs(r'D:\pythoncode\p1\girl.jpg')
# print(r)
# r = os.path.isabs(r'../girl.jpg')
# print(r)

#
# path = os.path.abspath('girl.jpg')
# print(path)

#
# path = os.path.abspath(__file__)
# print(path)

#
# path = os.getcwd() # os.path.dirname(__file__)
# print(path)

#
# result = os.path.split(path)
# print(result[1])

#
# result = os.path.splitext(path)
# print(result)

# ,
# result = os.path.getsize(path)
# print(result)

# ,
# all = os.listdir(r'D:\pythoncode\p1')
# print(all)

#
# if not os.path.exists(r'D:\pythoncode\p3'):
# f = os.mkdir(r'D:\pythoncode\p3')
# print(f)

# ,
# f = os.rmdir(r'D:\pythoncode\p3')
# print(f)
# path = r'D:\pythoncode\p3'
# file_list = os.listdir(path)
# for file in file_list:
# path1 = os.path.join(path, file)
# os.remove(path1)
# else:
# os.rmdir(path)
# print(' ')

#
f = os.chdir(r'D:\pythoncode\p2')
print(f)
path = os.getcwd()
print(path)

좋은 웹페이지 즐겨찾기