Pythonのファイルパス

Pythonのファイルパス

OSインポート
インポートSYS
strSelfPath = sys.argvの[0]
印刷(strSelfPath)
strDir、strFullName = os.path.split(strSelfPath)
プリント(strDir、strFullName)
STRNAME、strExtension = os.path.splitext(strFullName)
プリント(STRNAME、 strExtension)
strNameNew STRNAME + = 'コピー'
strSelfPathNew = os.path.join(strDir、strNameNew + strExtension).replace( '\'、 '/')
印刷(strSelfPathNew)
strSelfPathNew = "\" %のS \ "" %strSelfPathNewファイルパスの扱いは、#のWindowsシステムの問題の上のスペースを持っている
プリント(strSelfPathNewを)

おすすめ

転載: www.cnblogs.com/dailycode/p/11955415.html