해결된 질문
작성
·
1.6K
0
import xlsxwriter
workbook = xlsxwriter.Workbook('C:\Users\사용자\Desktop\알고리즘\tutorial_1_1.xlsx')
worksheet = workbook.add_worksheet('camp')
worksheet.write('a1', 'a')
worksheet.write('b1', 'b')
worksheet.write('c1', 'c')
worksheet.write('d1', 'd')
worksheet.write('e1', 'e')
worksheet.write('a2', 1)
worksheet.write('b2', 2)
worksheet.write('c2', 3)
worksheet.write('d2', 4)
worksheet.write('e2', 5)
worksheet.write(2,0, 'a')
worksheet.write(2,1, 'b')
worksheet.write(2,2, 'c')
worksheet.write(2,3, 'd')
worksheet.write(2,4, 'e')
worksheet.write(3,0, 10)
worksheet.write(3,1, 20)
worksheet.write(3,2, 30)
worksheet.write(3,3, 40)
worksheet.write(3,4, 50)
workbook.close()
실행을 하면 에러가 납니다 ㅠㅠㅠ
File "<ipython-input-8-196d49d449e6>", line 3 workbook = xlsxwriter.Workbook('C:\Users\사용자\Desktop\알고리즘\tutorial_1_1.xlsx') ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
답변 4
0
0
경로바꿔서 해봤는데 에러메세지는 같네요 ㅠㅠ
혹시나 해서 구글코랩으로 했더니
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e3f96d2f55ad> in <module>() ----> 1 import xlsxwriter 2 3 workbook = xlsxwriter.Workbook('./tutorial_1_1.xlsx') 4 5 worksheet = workbook.add_worksheet('camp')
ModuleNotFoundError: No module named 'xlsxwriter'
--------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below. ---------------------------------------------------------------------------
이렇게 뜹니다
0
검색해보니 경로상의 Users 부분이 문제네요
\U 가 파이썬에서 유의미한 키워드라 오류가 발생한다고 합니다.
# 이렇게 하시거나
xlsxwriter.Workbook('C:\\Users\\사용자\\Desktop\\알고리즘\\tutorial_1_1.xlsx')
# 혹은r을 붙이세요
xlsxwriter.Workbook(r'C:\Users\사용자\Desktop\알고리즘\tutorial_1_1.xlsx')
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) D:\anaconda\lib\site-packages\xlsxwriter\worksheet.py in cell_wrapper(self, *args, **kwargs) 62 first_arg = args[0] ---> 63 int(first_arg) 64 except ValueError: ValueError: invalid literal for int() with base 10: 'a1' During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) <ipython-input-10-046be8febccb> in <module> 5 worksheet = workbook.add_worksheet('camp') 6 ----> 7 worksheet.write('a1', 'a') 8 worksheet.write('b1', 'b') 9 worksheet.write('c1', 'c') D:\anaconda\lib\site-packages\xlsxwriter\worksheet.py in cell_wrapper(self, *args, **kwargs) 64 except ValueError: 65 # First arg isn't an int, convert to A1 notation. ---> 66 new_args = xl_cell_to_rowcol(first_arg) 67 args = new_args + args[1:] 68 D:\anaconda\lib\site-packages\xlsxwriter\utility.py in xl_cell_to_rowcol(cell_str) 119 120 match = range_parts.match(cell_str) --> 121 col_str = match.group(2) 122 row_str = match.group(4) 123 AttributeError: 'NoneType' object has no attribute 'group'
그걸 붙이니 이런 거대한 에러가.....
그러네요 성공했습니다 감사합니다