algorithmic modeling for Rhino
hi I am trying to make the follow snippet work :
import os,sys
reload(sys)
sys.setdefaultencoding('UTF8')
line_number = 0
with open('C:\1.txt', encoding='utf-8') as a_file: #utf-8(linux) or cp1252(windows)
for a_line in a_file:
line_number += 1
print('{:>4} {}'.format(line_number, a_line.rstrip()))
so that it can read from multiple
also the text is in a foreign language, korean.
I tried with a txt file in english but throws the same error :
1. Solution exception:open() got an unexpected keyword argument 'encoding'
Any ideas? A bit in a hurry. Thank you.
Tags:
Hi Youngjae,
This means that open() does not have an encoding option.
https://docs.python.org/2/library/functions.html#open
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by