Python
1import pandas as pd 2import os 3 4os.chdir("C:\Users\kyamasita\PycharmProjects\exchange\coin") 5 6doll=pd.read_csv("Doll.csv") 7doll
以上のようにcsvファイルを開こうとしたらpycharmで別に_pydev_excelfile.pyと新たなファイルが現れ、以下のようなコードが描かれていました。
Python
1 2#We must redefine it in Py3k if it's not already there 3def execfile(file, glob=None, loc=None): 4 if glob is None: 5 import sys 6 glob = sys._getframe().f_back.f_globals 7 if loc is None: 8 loc = glob 9 10 # It seems that the best way is using tokenize.open(): http://code.activestate.com/lists/python-dev/131251/ 11 import tokenize 12 stream = tokenize.open(file) # @UndefinedVariable 13 try: 14 contents = stream.read() 15 finally: 16 stream.close() 17 18 #execute the script (note: it's important to compile first to have the filename set in debug mode) 19 exec(compile(contents+"\n
Qlita等で調べたとおりにしたはずなのですがどこがエラーになっているのか教えて頂けたら有難いです
-追記
Connected to pydev debugger (build 181.5540.17)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\pydevd.py", line 1664, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/kyamasita/PycharmProjects/exchange/doll.py", line 4
os.chdir("C:\Users\kyamasita\PycharmProjects\exchange\coin")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。