Moin,
folgendes Problem. Ich nutze splitext() um Extension und Dateiname zu trennen. Das funktioniert super, wenn man den Path-String direkt vorgibt. Es funktioniert nicht, wenn man die Datei mit dem FileDialog auswählt. Und das obwohl beide Male eigentlich der PfadString an splitext() weitergegeben wird.
Miniprogramm:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # main.py #!/usr/bin/python import sys from PyQt4 import QtCore, QtGui import os.path def main(): app = QtGui.QApplication(sys.argv) afd = QtGui.QFileDialog() # afileN = "/home/jazz/Entwicklung/brief_latex/tex/brief.tex" afileN = afd.getOpenFileName() print afileN print os.path.splitext(afileN) sys.exit(app.exec_()) if __name__ == '__main__': main() |
und konsolenausgabe für den Dialog-Fall:
File "/usr/lib/python2.6/posixpath.py", line 95, in splitext return genericpath._splitext(p, sep, altsep, extsep) File "/usr/lib/python2.6/genericpath.py", line 91, in _splitext sepIndex = p.rfind(sep) AttributeError: rfind
Hat jemand ne Idee woran das liegen könnte?